-
-
Notifications
You must be signed in to change notification settings - Fork 353
Using GlslViewer
In the most simple scenario you just want to load a fragment shader. For that you need to:
- Run the app passing the shader as an argument
cd examples
glslViewer 2D/00_tests/test.frag
- Then edit the shader with your favorite text editor.
vim 2D/00_tests/test.frag
Note: In RaspberryPi you can avoid taking over the screen by using the -l
flags so you can see the console. Also you can edit the shader file through ssh/sftp.
Note: On Linux and macOS you may used to edit your shaders with Sublime Text, if that's your case you should try this Sublime Text 2 plugin that launch glslViewer every time you open a shader.
You can also load both fragments and vertex shaders. Of course modifying a vertex shader makes no sense unless you load an interesting geometry. That's why glslViewer
can load .ply
files. Try doing:
glslViewer 3D/00_pipeline/00_background.frag 3D/00_pipeline/head.ply
You can load images (PNG, JPEG, TGA, BMP, HDR, PSD, GIF) or videos (files like MOV, MP4; capture devices like /dev/video0
; or streamming urls like: RTSP, RTMP, HTTP, HTTPS) to a shader. They will be automatically loaded and assigned to a uniform name according to the order they are passed as arguments: ex. u_tex0
, u_tex1
, etc. Also the resolution will be assigned to vec2
uniform according to the texture uniform's name: ex. u_tex0Resolution
, u_tex1Resolution
, etc.
glslViewer 2D/00_tests/test.frag 2D/00_tests/test.png
glslViewer 2D/00_tests/test.frag /dev/video0
glslViewer 2D/00_tests/test.frag rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov
In case you want to assign custom names to your textures uniforms you must specify the name with a flag before the texture file. For example to pass the following uniforms uniform sampler2D imageExample;
and uniform vec2 imageExampleResolution;
is defined in this way:
glslViewer shader.frag -imageExample image.png
Beside for texture uniforms other arguments can be add to glslViewer
:
-
-x <pixels>
set the X position of the billboard on the screen -
-y <pixels>
set the Y position of the billboard on the screen -
-w <pixels>
or--width <pixels>
set the width of the billboard -
-h <pixels>
or--height <pixels>
set the height of the billboard -
--headless
headless rendering. Very useful for making images or benchmarking. -
--life-coding
or-l
open glslViewer on live-codeing mode. In the RaspberryPi will draw the viewport in a 500x500 billboard on the top right corner of the screen that let you see the code and the shader at the same time. While in MacOS and Linux will display the windows always-on-top (this requires GLFW 3.2). -
--fullscreen
or-f
open glslViewer in fullscreen -
--screensaver
or-ss
run in screensaver mode (fullscreen mode and any mouse or key event will exit) -
--holoplay <0/1/2>
open glslViewer on a Looking Glass holo display in different levels of definition -
--nocursor
hides the cursor -
--fxaa
adds a FXAA as postprocessing filter -
-e <command>
execute command when start. Multiple-e
flags can be chained -
-E <command>
execute command then exit -
-p <OSC_LISTENTING_PORT>
listen for OSC commands -
-I<include_folder>
add an include folder to default for#include
files -
-D<KEYWORD>
add system#define
s directly from the console argument -
-vFlip
all textures after will be flipped vertically -
--fps <fps>
fix your frames per seconds to a specific rate -
--video <video_device_number>
open video device allocated wit that particular id -
--audio <capture_device_id>
open audio capture device allocated as sampler2D texture. If id is not selected, default will be used -
-<texture_uniform_name> <texture>.(png|jpg|hdr)
add textures associated with differentuniform sampler2D
names -
-c <environmental_map>.(png/jpg/hdr)
load a environmental map (cubemap or sphericalmap) -
-C <enviromental_map>.(png/tga/jpg/bmp/psd/gif/hdr)
load a environmental map as cubemap -
-sh <enviromental_map>.(png/tga/jpg/bmp/psd/gif/hdr)] - load a environmental map as spherical harmonics array
-
-v
or--version
return glslViewer version -
--verbose
turn verbose outputs on -
--help
display the available command line options
Once glslViewer is running the CIN is listening for some commands, so you can pass data through regular *nix pipes.
-
[uniform_name],[int|float][,float][,float][,float][,float]
: uniforms (int
,floats
,vec2
,vec3
andvec4
) can be pass as comma separated values (CVS), where the first column is for the name of the uniform and the rest for the numbers of values. Values are strong typed (1
is not the same as1.0
). Ex:
u_myInt,13
u_myfloat,0.5
u_myVec2,1.0,0.1
u_myVec3,0.0,0.5,0.0
...
Note that there is a distinction between int
and float
so remember to put .
(floating points) to your values.
-
help[,<command>]
print help for one or all command -
version
return glslViewer version. -
debug,[on|off]
turn debug mode on or off. -
window_width
return the width of the windows. -
window_height
return the height of the windows. -
pixel_density
return the pixel density. -
screen_size
return the screen size. -
viewport
return the viewport size. -
mouse
return the mouse position. -
fps[,<fps_number>]
return or set the number of frames per second. -
delta
returnu_delta
, the secs between frames. -
time
returnu_time
, the elapsed time. -
date
returnu_date
as YYYY, M, D and Secs. -
frag[,<line_number>|<filename>]
return a line or save the entire fragment shader source code. -
vert[,<line_number>|<filename>]
return a line or save the entire vertex shader source code. -
dependencies[,vert|frag]
return a list of all the dependencies of the vertex or fragment shader or both. -
files
return a list of files. -
reload[,<filename>]
reload one or all files -
'reset' resets the elapsed timestamp to zero
-
update
force all uniforms to be updated -
fullFps[,on|off]
go to full FPS or not -
cursor[,on|off]
show/hide cursor -
buffers[,on|off]
return a list of buffers as their uniform name, if it'son
it will show them on screen. -
textures[,on|off]
return a list of the textures or show/hide them on the viewport -
grid[,on|off]
show/hide grid -
axis[,on|off]
show/hide axis -
bboxes[,on|off]
show/hide bounding box -
histogram[,on|off]
show/hide histogram -
error_screen[,on|off]
show/hide magenta error screen on error. When off will keep playing the previous code. -
defines
return a list of active defines -
define,<KEYWORD>[,<VALUE>]
add a define to the shader -
undefine,<KEYWORD>
remove a define on the shader -
uniforms[,all|active]
return a list of all uniforms and their values or just the one active (default). -
textures[,on|off]
return a list of textures as their uniform name and path. If it'son
will show them on screen -
camera_distance[,<dist>]
get or set the camera distance to the target. -
camera_position[,<x>,<y>,<z>]
get or set the camera position. -
camera_fov[,<field_of_view>]
get or set the camera field of view. -
camera_exposure[,<aper.>,<shutter>,<sensit.>]
get or set the camera exposure values. -
lights
get all light data. -
light_position[,<x>,<y>,<z>]
get or set the light position. -
light_color[,<r>,<g>,<b>]
get or set the light color. -
light_falloff[,<value>]
get or set the light falloff distance. -
light_intensity[,<value>]
get or set the light intensity. -
models
return a list of all models -
model,<NAME>
return a list of mesh properties, vertex attributes and defines for a given model -
materials
return a list defines for a given material -
material,<NAME>
return the defines for a given model -
blend[,<alpha|add|multiply|screen|substract>]
get or set the blending modes -
culling[,<none|front|back|both>]
get or set the culling modes -
dynamic_shadows[,on|off]
get or set dynamic shadows -
depth_test[,on|off]
turn on/off depth test -
cubemap[,on|off]
show/hide cubemap -
skybox[,on|off]
show/hide skybox -
skybox_ground[,<r>,<g>,<b>]
get or set the ground color of the skybox. -
skybox_elevation[,<sun_elevation>]
get or set the sun elevation (in rads) of the skybox. -
skybox_azimuth[,<sun_azimuth>]
get or set the sun azimuth (in rads) of the skybox. -
skybox_turbidity[,<sky_turbidty>]
get or set the sky turbidity of the skybox. -
model_position[,<x>,<y>,<z>]
get or set the model position. -
floor[,on|off|subD_level]
show/hide floor or presice the subdivision level -
screenshot[,<filename>]
save a screenshot to a filename. -
max_mem_in_queue[,<bytes>]
get or set the maximum amount of ram in bytes which is used to queue up images generate by thesequence
command for saving to disk. Note: a low amount of memory can and will result in a bad multicore utilisation. Therefore: tune this number carefully! -
secs,<A_sec>,<B_sec>
save a sequence of images from A to B second. -
frames,<A_sec>,<B_sec>
save a sequence of images from frame A to frame B. -
wait,<seconds>
wait<seconds>
until executing the next command -
q
,quit
orexit
: close glslViewer