ShaderShark is an OpenGL/X11 application for GNU/Linux consisting of a single window that shows simple 3D scene of a textured rectangle with applied vertex and fragment shaders (GLSL).
There are no buttons, no text editors, just the 3D scene. The user is expected to use his own favourite text editor to edit the shaders and just save the file – the save operation from the external editor triggers reload of the shader or texture in ShaderShark.
This tool was created for our internal purposes and is published as is without any guarantees. In the future, it might become a product (however still free software, of course) with regular releases, but we are not there yet.
Environment variables:
SHADER_SHARK_DATA_DIR
– should point to a place where shaders
and
textures
directories are located;
is used to load defaults when no shaders/textures are specified;
can point to the ShaderShark source directory
DISPLAY
– standard X11 variable;
can be used to run the application on different display;
usually keep default that is already set
Extended attributes:
shader-shark.texture.mag-filter
– can be set on the texture file to specify the
GL_TEXTURE_MAX_FILTER
i.e. method of scaling
smaller texture to larger surface;
possible values are:
nearest
(sharp, pixelated) and
linear
(blurry, soft)
shader-shark.texture.min-filter
– same, just for GL_TEXTURE_MIN_FILTER
shader-shark.texture.scale
– normal value is 1.
or empty,
but if the texture was upscaled e.g. from 320×240
to 640×480, we set this attribute to 2.0
;
this value is then passed to the shaders, so they
will know the original/logical texture dimensions;
this is useful for drawing lines or grids that should
fit the gaps between the original pixels
Command line arguments:
--texture
– texture to load, e.g. PNG or JPEG file
--shader
– first argument is shader type
(vertex
or fragment
)
and second one is the file name;
when missing, default shader is loaded
--background-color
– RGB color code in hexadecimal,
like
147258
, 333333
, 345678
etc.
--root-window
– specify an X11 window ID
(as decimal or hexadecimal integer)
to embed ShaderShark into an existing window
Controls:
ShaderShark is controlled mainly by the keyboard. It expects fingers on the home row, thus it is ESDF not WASD. Left hand does move forward/backward, rotate left/right and roll left/right. Right hand does move left/right (three different speeds) and move up/down.
Basic usage is just:
shader-shark --texture "some.png" --shader fragment "hello.frag"
Bash-completion script is provided.
It is not necessary to restart ShaderShark
to reload a texture or a shader – it monitors the files
(using inotify) and reloads them when needed.
It reacts to the CLOSE_WRITE
so when the editor finishes writing, ShaderShark loads new content.
(editors that delete original file and create a new one
will not work with current version of ShaderShark – use other editor
or e.g. cat some-texture.png > temp.png
)
Common workflow is to open ShaderShark and text editor windows side by side and have some fun with GLSL when having live preview of what tha shader does.
The first demo that shows usage of ShaderShark: keyboard and mouse controls, loading textures, applying shaders, error handling, writing simple scanline and phosphor shaders, editing properties of a texture (xattr), ideas for further development.
Extended attributes editor used in the video: rozsirene-atributy (configuration script: xattr-editor.sh).
Graphics utilities are free software © 2023 GlobalCode