// $LastChangedDate: 2009-05-19 20:41:43 -0400 (Tue, 19 May 2009) $
// Compute color (vertex shader).

    // Compute color.
    vec4 ambient  = vec4( 0.10, 0.10, 0.05, 0.0 );
    vec4 diffuse  = vec4( 0.10, 0.10, 0.05, 0.0 );
    vec4 specular = vec4( 0.15, 0.15, 0.10, 0.0 );
    const vec3 normal = normalize( gl_NormalMatrix * gl_Normal );
    const int  NumEnabledLights = 1;
    const vec3 eye = vec3( 0.0, 0.0, 1.0 );
    const vec3 ecPosition3 = ecPosition.xyz / ecPosition.w;
    // Loop through enabled lights, compute contribution from each.
    for ( int i = 0; i < NumEnabledLights; ++i )
    {
        if ( gl_LightSource[i].position.w == 0.0 )
            DirectionalLight(i, normal, ambient, diffuse, specular);
        else if ( gl_LightSource[i].spotCutoff == 180.0 )
            PointLight( i, eye, ecPosition3, normal, ambient, diffuse, specular );
        else
            SpotLight( i, eye, ecPosition3, normal, ambient, diffuse, specular );
    }                                                                  
    var_colorAmbientEmissive = gl_FrontLightModelProduct.sceneColor + ambient * gl_FrontMaterial.ambient;
    gl_FrontColor            = var_colorAmbientEmissive + diffuse * gl_FrontMaterial.diffuse;
    gl_FrontSecondaryColor   = vec4(specular * gl_FrontMaterial.specular);
    gl_BackColor             = gl_FrontColor;
    gl_BackSecondaryColor    = gl_FrontSecondaryColor;
