It's just like Shadertoy but as a command line tool.
This is a toy project of mine, so no guarantees are made about its quality or functionality. It is also bound to change suddenly.
$ shader-playground.exe
Expected 1 arguments, got 0
Usage: $ shader-playground.exe path\to\fragment.glsl
Passing in the path to a GLSL v330 fragment shader will open a window with the shader running.
Currently, the only uniforms provided are:
iReolution
:ivec2
for the current window size in pixelsiTime
:float
for the time since the program started
There are some written fragment shaders in the examples
directory.
This one is an adaptation of the default program when you create a new shader in Shadertoy:
$ shader-playground examples/shadertoy_gradient.glsl
This program depends on these things:
- GLFW as the graphics framework
- This framework is built with CMake
- GLAD to manage OpenGL loading
- This program runs using python
- zig 0.11.0 as the build system
Cloning recursively will fetch GLFW as a submodule:
$ git clone --recursive https://github.com/ethanavatar/shader-playground.git
Use CMake to build GLFW:
# Generate build files for your platform
$ cmake -B deps/glfw/build -S deps/glfw/
# Build the library binaries (`-j` for multithreading)
$ cmake --build deps/glfw/build -j
Generate GLAD C-Bindings:
# Install/upgrade glad
$ pip install glad --upgrade
# Generate C bindings
$ python -m glad --profile core --out-path deps/glad --generator c --api gl=3.3 --spec gl
Build shader playground with zig:
$ zig build -Dtarget=native-native-msvc -Doptimize=ReleaseSafe
The build.zig
has been made with only windows in mind. So It would require modifications for other platforms.
You can also run the program from zig-build:
$ zig build run -Dtarget=native-native-msvc -Doptimize=ReleaseSafe -- examples/shadertoy_gradient.glsl