Graphics Reference
In-Depth Information
Copy the color from the atribute variable aColor to an out variable such
as vColor .
Set an out variable such as vLightIntensity with the light intensity
based on diffuse lighting computations at this vertex.
Set an out variable such as vECposition with the eye coordinates of the
vertex.
The fragment shader carries out all the interesting computations that
simulate spot lighting for glman use. The positions of the light, the eye, and a
focal point of the light are set in eye space to define two vectors that meet at the
focal point, and uniform slider variables are used to set the angle of the light
and the horizontal location (the variable LeftRight ) of the light focal point.
The cosine of the angle set by the vectors is compared with the cosine of the
cutoff angle in a smoothstep( ) function to determine the amount of diffuse
light to include for each pixel. The simulation uses a number of parameters
that would normally be taken from the uniform lighting variables provided by
the system. See the GLSL API for more details.
uniform float uAngle;
uniform float uLeftRight;
uniform float uWidth;
in vec4 vColor;
in float vLightIntensity;
in vec3 vECposition;
out vec4 fFragColor;
const vec4 LIGHTPOS = vec4(0.,0.,40.,1.);
const float AMBCOEFF = 0.5;
// simulate ambient reflection coefficient
const float DIFFCOEFF = 0.6;
// simulate diffuse reflection coefficient
void main( )
{
// stubs for data in system attribute variables
// simulate MC light position
vec3 ECLightTarget = vec3( uModelViewMatrix *
vec4( uLeftRight, 0., 1.5, 1. ) );
vec3 LightDirection = normalize( ECLightTarget - LIGHTPOS );
vec3 EyeDirection = normalize( vECposition - LIGHTPOS );
// Ambient only
Search WWH ::




Custom Search