View Full Version : Vizard Headlight in Shader

06-26-2012, 10:52 AM
Dear Vizard Support,

I am trying to use your headlamp in some shader code for lighting an procedurally generated terrain.

I am using on-the-fly objects to create the terrain.

My shader is attempting to access the headlamp through gl_LightSource[0]. However, I am unsure as to what type of light the headlamp is. Is it a directional, positional or spot light?

When I attempt to access the position information from gl_LightSource[0].position I get a value that does not appear to match my actual lamp direction.

vec3 normal = normalize(gl_NormalMatrix * gl_Normal);
vec3 lightPos = normalize(vec3(gl_LightSource[0].position));
dotted = max( dot(normal, lightPos), 0.0 );

I am really looking for a better understanding of the headlight in Vizard and how it would be properly integrated into a shader.

06-27-2012, 01:19 PM
The default headlight is a directional light. If you are accessing the light in a fragment shader, then the direction vector will be stored in gl_LightSource[0].position.xyz.