Can someone explain why the following

void mainImage(out vec4 fragColor, vec2 fragCoord) { switch (1) { case 0: fragColor = vec4(1.0,1.0,1.0,1.0);; break; default: fragColor = vec4(0.0,0.0,0.0,1.0);; break; } }

Works fine on ShaderToy but I get a "switch" keyword error in Vuo.

Comments

Hi Paul!

ops's picture
Submitted by

Hi Paul! I'm not a Shader guru but I think the version of the GLSL doesn't accept the Switch case. But I think that a solution is to write if/else conditionals and will work ( If(condition){ else{...} )

PD: Thanks a lot for your immersive work. Much appreciated.

Oh sure, the if-then-else

pbourke's picture
Submitted by

Oh sure, the if-then-else solution is obvious.

Just curious that Shadertoy works and the node is called "Make image with Shadertoy" ... so at the every least the documentation for that node should say something about restructions. Shaders are hard enough to debug as it is. :-)

Paul,

jmcc's picture
Submitted by

Paul,

We've added documentation to the node:

"This node uses GLSL 1.20. Features that were added in later versions of GLSL, such as switch statements, may not be supported."