Original Post
Just wondering about this one. I've been trying to build some dynamic shaders by placing uniforms in them that can act as "on/off" switches for different functions. One that I recently tried was for the option of doing a 3x3 shadowmap blur. The uniform is a float that I set to 0.0 if I want the function to be performed, or 1.0 if I don't. The code in the shader is straight forward: float sum = 0.0; if (shadowsActive < 1.0) { //// Single Pixel Lookup And sum//// sum = lookup(0.0, 0.0); //// 3x3 /////////////////////////// if (useSoftShadows < 1.0) { sum += lookup(1.0, 0.0); sum += lookup(-1.0, 0.0); sum += lookup(0.0, 1.0); sum += lookup(0.0, -1.0); sum += lookup(1.0, 1.0); sum += lookup(-1.0, 1.0); sum += lookup(-1.0, -1.0); sum += lookup(1.0, -1.0); sum /= 9.0; } } else { sum = 1.0; } The interesting problem is, even if "useSoftShadows" is set to 1.0, I still get the performance hit as if all the lookups were happening (even though they are not, which I've verified). Why is this? And is there a way around this?