I want to accomplish a GLSL Shader, that can texture and color my vertex objects. In fact, it works for me in 2 from 3 cases:
1) If I only have an texture assigned (but no specific color - so the color is "white"), I simply get an textured object - works
2) If I have an texture and an color assigned, I get an textured Object modulated with that color - works
3) If I only have an color assigned but no texture, I get an black object - doesn't work
My Shader looks like this:
varying lowp vec4 colorVarying;
varying mediump vec2 texcoordVarying;
uniform sampler2D texture;
void main(){
gl_FragColor = texture2D(texture, texcoordVarying) * colorVarying;
}
I guess that, texture2D(...,...) returns zero if no texture is assigned - so that seems to be the problem. Is there a way in GLSL I can check, if no texture is assigned (in this case, I want simply gl_FragColor = colorVarying;)
"If" isn't really an option in an GLSL Shader, if I understanded correctly - any ideas to accomplish this? Or is it really necessary to make 2 different shaders for both cases?