Like you I'd picked up the general advice that 'if' is to be avoided on current mobile hardware, but a previous optimisation discussion on StackOverflow seemed to suggest it wasn't a significant hurdle. So don't write it off. In any case, the GLSL compiler is reasonably smart and may chose to switch which code it actually runs depending on the values set for uniforms, though in that case all you're getting is the same as if you'd just supplied alternative shaders That said, if you're absolutely certain you want to use the same shader for all purposes and want to avoid if statements then you probably want something like: uniform lowp float textureFlag; ... gl_FragColor = textureFlag * texture2D(texture, texcoordVarying) * colorVarying + (1.0 - textureFlag) * colorVarying Or even: gl_FragColor = mix( colorVarying, texture2D(texture, texcoordVarying) * colorVarying, textureFlag ) With you setting textureFlag to 1.0 or 0.0 depending on whether you want the texture values to be factored in I'm not aware of any way to determine (i) whether a sampler2D is pointed to an actual texture unit; and (ii) whether a particular texture unit has a buffer bound to it for which data has been uploaded.
Like you I'd picked up the general advice that 'if' is to be avoided on current mobile hardware, but a previous optimisation discussion on StackOverflow seemed to suggest it wasn't a significant hurdle. So don't write it off. In any case, the GLSL compiler is reasonably smart and may chose to switch which code it actually runs depending on the values set for uniforms, though in that case all you're getting is the same as if you'd just supplied alternative shaders.
That said, if you're absolutely certain you want to use the same shader for all purposes and want to avoid if statements then you probably want something like: uniform lowp float textureFlag; ... gl_FragColor = textureFlag * texture2D(texture, texcoordVarying) * colorVarying + (1.0 - textureFlag) * colorVarying; Or even: gl_FragColor = mix( colorVarying, texture2D(texture, texcoordVarying) * colorVarying, textureFlag ) With you setting textureFlag to 1.0 or 0.0 depending on whether you want the texture values to be factored in. I'm not aware of any way to determine (i) whether a sampler2D is pointed to an actual texture unit; and (ii) whether a particular texture unit has a buffer bound to it for which data has been uploaded.
1 I think you mean textureFlag and textureMask to have the same variable name – brian_d Oct 6 at 23:29 You're completely right. And I threw in the alternative of using mix, since I was editing anyway. I'm pretty sure I have those arguments the right way around.
– Tommy Oct 7 at 11:10.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.