Live tool for developing OpenGL shaders interactively
Find a file
2021-03-07 19:27:17 +01:00
.github/workflows Add GitHub Actions workflow to build and deploy documentation 2021-03-01 21:28:25 +01:00
images Add images 2021-03-07 19:27:17 +01:00
shaders Add resources and references 2021-03-07 18:28:32 +01:00
src Move shader initialization to a separate function 2021-03-05 20:05:09 +01:00
.gitignore Add images 2021-03-07 19:27:17 +01:00
Doxyfile Use the README as the documentation main page 2021-03-07 17:57:23 +01:00
LICENSE Add LICENSE file 2021-02-24 22:43:27 +01:00
meson.build Separate all I/O functions in a separate file 2021-03-01 21:00:44 +01:00
README.md Add images 2021-03-07 19:27:17 +01:00

ShaderTool

build docs

Live tool for developing OpenGL shaders interactively.

psychedelic bacteria julia

I developed this small program to experiment with shaders locally, to reproduce an experience like Shadertoy offline, with the ability to choose my own text editor. It was also a good project to learn OpenGL development. For this reason, the code is very minimal and should be fairly readable.

Additional features:

  • Extensive logging (using the nice log.c library)
  • FPS tracking
  • Reload shaders automatically on save (using inotify)
  • Save screenshot to a file
  • Complete argument parsing with Argp
  • Full documentation with Doxygen

Build

This project requires the GLFW, GLEW, and FreeImage libraries. On a Debian/Ubuntu system:

sudo apt-get install libglfw3-dev libglew-dev libfreeimage-dev

To build (with Meson):

meson build
ninja -C build

To build the documentation with Doxygen:

doxygen Doxyfile

The documentation is also available online.

Usage

Usage: shadertool [OPTION...] SHADER
                                    Compile and render the SHADER.
ShaderTool -- Live tool for developing OpenGL shaders interactively

  -b, --buffer=FILE          Source file of the buffer fragment shader
  -r, --auto-reload          Automatically reload on save
  -s, -q, --silent, --quiet  Don't produce any output
  -v, --verbose              Produce verbose output
  -?, --help                 Give this help list
      --usage                Give a short usage message
  -V, --version              Print program version

For instance, to run the mandelbrot shader with live reloading on save:

shadertool -r shaders/mandelbrot.frag

Keyboard shortcuts:

  • Escape to quit
  • R to reload the shaders
  • S to save a screenshot to the current directory, in a file shadername_frame_date_time.png

Limitations

For now, the "buffer" shader (i.e. the additional shader that renders in a texture in another framebuffer) does not work properly. I don't understand exactly what's broken, but maybe I'll investigate it more closely later. If you have any idea about what went wrong, don't hesitate to notify me!

References and other resources