Somehow, modifying gl_FragColor does not change the final color of my 3D objects. How can this be possible? This has only happened suddenly ... as the EXACT SAME CODE was working before ...
Fragment Shader:
#version 120
uniform vec4 ambient;
uniform vec4 diffuse;
uniform vec4 specular;
uniform vec4 objColor;
uniform float shininess;
uniform bool shade;
uniform sampler2D texMap;
varying vec2 st;
varying vec3 N;
varying vec3 L;
varying vec3 E;
void main(void) {
vec3 NN = normalize(N);
vec3 EE = normalize(E);
vec3 LL = normalize(L);
vec3 H = normalize(LL+EE); //Half vector
float Kd = dot(LL, NN);
float Ks = pow(max(dot(NN, H), 0.0), shininess);
vec4 amb, diff, spec;
amb = ambient;
diff = Kd*diffuse;
if(Kd <= 0.0) spec = vec4(0.0, 0.0, 0.0, 1.0);
else spec = specular * Ks;
if(shade) gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); <----------------- THIS LINE
else gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); <---------------------- THIS LINE
}
Vertext Shader:
#version 120
uniform mat4 projection_matrix;
uniform mat4 modelview_matrix;
uniform mat4 transform_matrix;
uniform vec4 light_position;
attribute vec2 a_Textcoord;
attribute vec4 a_Vertex;
attribute vec4 a_Normal;
varying vec2 st;
varying vec3 N;
varying vec3 L;
varying vec3 E;
void main(void) {
vec4 clip_position = transform_matrix * a_Vertex;
gl_Position = projection_matrix * modelview_matrix * clip_position;
vec4 nn = transform_matrix * a_Normal;
N = normalize(nn.xyz);
L = light_position.xyz - clip_position.xyz;
if(light_position.w == 0.0) L = light_position.xyz;
E = clip_position.xyz;
st = a_Textcoord;
}
As indicated in the Fragment Shader, "<----- THIS LINE", any object I shader, is BLACK instead of Red. I have checked all variable values sending into the shader, they match what's expected and ModelView Matrix and Projection Matrix works fine. Anyone got any ideas why this is the case?