Skip to content

ethanavatar/shader-playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

shader playground

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.

Usage

$ 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 pixels
  • iTime: 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

Building from Source

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