I've written a fragment shader that works with one variable declaration but breaks with another that is mathematically identical. I have edited the code snippet to highlight the two alternatives for thetastrt_2
. PI
is properly defined and partsnum
is a float that equals 3.0 -
fragmentShader: [
"uniform vec3 mixfinal;",
//more uniforms
"vec3 mixer () {",
" vec3 lightOG = vec3 ( 0.0 );",
" float thetastrt_0 = PI / 2.0;",
" if ( partsnum >= 2.0 ) {",
" float thetastrt_1 = thetastrt_0 + ( PI * 2.0 / partsnum );",
//more code
" }",
" if ( partsnum >= 3.0 ) {",
" float thetastrt_2 = thetastrt_0 + ( PI * 4.0 / partsnum );", //shader works
" float thetastrt_2 = thetastrt_1 + ( PI * 2.0 / partsnum );", //shader breaks
//more code
" }",
" return lightOG;",
"}", //end mixer ()
"void main() {",
" vec3 outgoingLight = vec3( 0.0 );",
" outgoingLight = mixer();",
//more code
"}"
With no debugger this was hard to find. Is this a run/compile time issue? Is the problem that thetastrt_2
depends on thetastrt_1
depends on thetastrt_0
?