A WGSL playground inspired by Shadertoy.
The application use a binary format wgs
to save and load shaders and textures.
It helps to share your shaders amoung people.
You can find examples in wgshader-examples.
The runtime currently provided six parameters you can use in your shader as a uniform variable:
cursor
: vec2- The mouse position in pixels.
mouse_down
: u32- Whether the left button of the mouse is down.
0
: left button is up.1
: left button is down.
mouse_press
: vec2- The mouse position in pixels when the left button is pressed.
mouse_release
: vec2- The mouse position in pixels when the left button is released.
resolution
: vec2- The resolution of the canvas in pixels (width * height).
time
: f32- The elapsed time since the shader first ran, in seconds.
You can use the above uniform like the following:
fn main_image(frag_color: vec4<f32>, frag_coord: vec2<f32>) -> vec4<f32> {
let uv = frag_coord / u.resolution;
let color = 0.5 + 0.5 * cos(u.time + uv.xyx + vec3(0.0, 2.0, 4.0));
return vec4(color, 1.0);
}
Check the latest release, and download the package for your specific OS.
Currently, msi for Windows, dmg for MacOS and raw executable for Linux are provided. If you are willing to contribute more packages (such as deb, rpm...), feel free to open a PR.
For Arch Linux users, there is already a package named wgshadertoy
in AUR, just install it:
yay -S wgshadertoy
- The amount of the texture you can upload is the max bind group count of your device - 1.
- Won't show any hints on invalid shaders. They just won't compile.
- Web version
- Advanced shader validation (detailed in fralonra#1)