Hi, I’m trying to do a simple point omniderectional light shader.
Here my code for vertex shader:
vec3 lightPos, vertexPos, normal, s;
varying float i;
void main()
{
normal = normalize( gl_NormalMatrix * gl_Normal );
vertexPos = vec3( gl_Vertex * gl_ModelViewMatrix );
lightPos = vec3( 0, 0, 0 );
s = normalize( lightPos - vertexPos );
// The diffuse shading equation
i = dot( s, normal );
gl_Position = ftransform();
}
and this is my fragment shader:
varying float i;
void main (void)
{
gl_FragColor = vec4( i, i, i, 1.0);
}
It doesn’t work fine. I see all my sphere black, and it is positionate in 0, 3, 0 coords.
Any help?