shadow icon indicating copy to clipboard operation
shadow copied to clipboard

Support for www.shadertoy.com shaders?

Open AverageLinuxEnjoyer opened this issue 3 years ago • 3 comments

Most of those require additional uniforms, like:


uniform vec3      iResolution;           // viewport resolution (in pixels)
uniform float     iTime;                 // shader playback time (in seconds)
uniform float     iTimeDelta;            // render time (in seconds)
uniform int       iFrame;                // shader playback frame
uniform float     iChannelTime[4];       // channel playback time (in seconds)
uniform vec3      iChannelResolution[4]; // channel resolution (in pixels)
uniform vec4      iMouse;                // mouse pixel coords. xy: current (if MLB down), zw: click
uniform samplerXX iChannel0..3;          // input channel. XX = 2D/Cube
uniform vec4      iDate;                 // (year, month, day, time in seconds)
uniform float     iSampleRate;           // sound sample

They also don't have a main function.

Any chance we'd get support for that?

AverageLinuxEnjoyer avatar Sep 20 '22 18:09 AverageLinuxEnjoyer

Nvm, saw your frag2.glsl file and figured out I just had to rename the variables and create a main function to call the shader function in.

AverageLinuxEnjoyer avatar Sep 20 '22 19:09 AverageLinuxEnjoyer

This isn't actually completely true, because some of these values simply don't exist in Shadow, or aren't currently exposed to the shader under any name. Even if all values were completely available, the preamble for remapping them can get somewhat complex, so it'd be best to at least provide a pre-made structural template that people can just paste at the start/end of their script; that template should be placed in a location that is more obvious than "some random nameless example shader".

And of course, the more flexible the mapping the better, and being able to select the script mapping style in the command line would still be nice. The good thing is that technically all of this can be implemented with the ability to execute python scripts as "shaders", which can manually construct the shader instrumentation and expose whatever values they want; but I don't really want anyone to have to deal with that for this simple use case. Additionally, this would be much nicer if script shaders could take command-line parameters (eg the actual shadertoy script file), but that'd be a separate feature request.

ilonachan avatar Jun 23 '25 13:06 ilonachan

Yes I agree, being able to pass values to the shader from the command line would be a neat feature to have. Also don't like the reliance of scripts especially considering security concerns one could have. I think the only "difficult" part with shadertoy is that many more complicated shaders on that site use multiple buffers or use channels for custom data. Somewhere you might want to configure all these parameters and I am not sure if having all of it in one long command prompt might not be a bit much.

danielfvm avatar Jun 24 '25 21:06 danielfvm