WorldViz User Forum

WorldViz User Forum (
-   Vizard (
-   -   Vizard Headlight in Shader (

shivanangel 06-26-2012 10:52 AM

Vizard Headlight in Shader
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.

farshizzo 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]

All times are GMT -7. The time now is 03:34 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC