We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi all,
Seeing how efficient shaders are at applying an effect to video frames, is there a way to convert any shader from Shadertoy to work in processing?
Thanks, Charles
Answers
as long someone prepared a better answer this just a hit in the right direction, - where to start
ShrtoyFrag.glsl
@nabr Would you mind clarifying your answer?
mainImage()
is already present in all ShaderToy shaders, thus, should it be replaced or appended? If the latter, then are the arguments also appended?I understand that
uniform
are variables that can be accessed from Processing, is it also possible to change other variables using theset()
function?@CharlesDesign Hello the mainImage is thought to make it easy to copy +paste from shadertoy mainImage to any kind of Shadercompiler like Processing. It is necessary to have a main function in the body of a shader. Shadertoy just hide it from you.
"should it be replaced or appended? " replaced
uniforms: I do not really understand, what you are trying to archive. uniform is just a instruction to the glsl Compiler, like int or float, string.
do the same thing with a uniform
the set() method overloads the ("declaration", value). you can change the value very easy Shrtoy.set("iGlobalTime", millis() / 1000.0); the millis are counted up, the value is changed every draw call. the iGlobalTime is a constant.
@CharlesDesign scroll down to uniforms https://www.khronos.org/opengl/wiki/Core_Language_(GLSL)
See also previous discussions of specific examples:
Based on your instructions I've converted the following Voronoi shader, however, I get the following error:
Here's the code directly from ShaderToy.com:
Here's my sketch:
And voronoid.glsl:
These are the unicorns on shadertoy. Whenever you use make sure you link it in your processing scetch.
https://ibb.co/gnXi35
Add to your scetch:
voronoi.set("iChannel0",get());
Add to your voronoid.glsl:
uniform sampler2D iChannel0
@CharlesDesign I discover some build in uniforms like on shadertoy
https://codeanticode.wordpress.com/2014/05/08/shader_api_in_processing_2/
voronoid.glsl:
Processing scetch: (no need to assign iChannel0)
PShader voronoi;
@nabr -- "uniforms", not unicorns ;)
@nabr Super helpful, thanks!