Shady is a rust-libraray to integrate shadertoy easier into your app. It also ships with a default application which uses the library: shady-app which is basically like a local shadertoy-desktop-app.
It supports fragment shaders written in wgsl and glsl. The app determines which shader-language is used by
looking at the file-extension like fragment.wgsl
or fragment.glsl
.
In general shady-app <path> --template
will likely be what you want to execute. For example:
# if you want to write the fragment shader in `wgsl`
shady-app /tmp/fragment.wgsl --template
# if you want to write the fragment shade rin `glsl`
shady-app /tmp/fragment.glsl --template
Currently the audio
uniform buffer is hidden behind a feature flag which is disabled per default since it's pretty unstable (but it works).
You'll have to build it your own with:
cargo run --release --features audio -- /tmp/fragment.wgsl --template
if you want to use the iAudio
buffer.
If you are using nix
with flakes: Simply run nix run github:TornaxO7/shady -- <path to shader> --template
and you are good to go.
You need to install rust opengl/vulkan and then you can run:
cargo run --release -- <path> --template
- Live reloading (after save)
- Audio uniform buffer
Currently implemented uniform buffers:
iTime
iResolution
iFrame
- (
iAudio
)
A demo can be seen here.
- The template itself is an example if you run
shady <path> --template
, you can start writing your shader - See in
shader-examples/
(runshady-app shader-examples/<file>
)
Currently, you can't just copy+paste the shaders from shadertoy due to some differences how shady-app and shadertoy are using the fragment shaders.
So for the time being, here's a little (hopefully full) checklist/guide about how to get a shader from shadertoy up and running by using shady-app
- Make sure that the shader from shadertoy uses the uniform buffers listed in
# Features
at most. - Start by creating a
glsl
template by adding the--template
argument (for example:shady-app /tmp/fragment.glsl --template
). - Open the fragment shader.
- Don't remove the
uniform
lines from the template! - Copy+Paste the shadertoy-fragment by replacing the
main
function. - Change the function
mainImage
tovoid main() { ... }
- Replace
fragCoord
withgl_FragCoord
. - You should be good to go (in most cases)
An example can be seen in shader-examples
. Inside, there's a link to the original shader and author.
Currently shady
is listening to your default output device.
Take a look into your settings (for example with pavucontrol, under "Recording") if shady is listening to the correct source.
For example on my system it looks like this (after starting pavucontrol):
You are able to write shaders similar to shadertoy and you have the uniform values iTime
and iResolution
but also iAudio
if you want to create something with music visualisation.
However it's mostly unstable and unpolished (for example gamma correction is missing), that's why I'm not creating a release (yet?) for the lib but also for the app.