Hey guys, long time lurker, first (well second really) time poster,
I’m a bit of a newbie when it comes to OGL, and I recently started playing around with shaders in lwjgl. I wanted to try lighting out first, and borrowed code for a simple vertex and fragment shader, which is as follows:
Vertex Shader
varying float diffuse_value;
void main() {
vec3 vertex_normal = normalize(gl_NormalMatrix * gl_Normal);
vec3 vertex_light_position = gl_LightSource[0].position.xyz;
diffuse_value = max(dot(vertex_normal, vertex_light_position), 0.0);
gl_FrontColor = gl_Color;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
Fragment Shader
varying float diffuse_value;
void main() {
gl_FragColor = gl_Color * diffuse_value;
}
Now, I’m drawing a basic 3D box to go along with this, which is just basic quads put together. However, when the program is run, instead of getting “lighting” so to speak, each face receives the same color/amount of light, thus the box goes in and out of being black and being colored.
Any help would be greatly appreciated!
-Quaker762