2009-07-15 22:49:36 +00:00
|
|
|
// -*-C++-*-
|
|
|
|
|
|
|
|
// Shader that uses OpenGL state values to do per-pixel lighting
|
|
|
|
//
|
|
|
|
// The only light used is gl_LightSource[0], which is assumed to be
|
|
|
|
// directional.
|
|
|
|
//
|
|
|
|
// Diffuse and ambient colors come from the gl_Color. This is
|
|
|
|
// equivalent to osg::Material::AMBIENT_AND_DIFFUSE.
|
|
|
|
|
2009-11-19 16:20:51 +00:00
|
|
|
varying vec4 diffuse, constantColor;
|
2009-07-15 22:49:36 +00:00
|
|
|
varying vec3 normal, lightDir, halfVector;
|
2009-11-17 06:23:21 +00:00
|
|
|
varying float fogCoord, alpha;
|
2009-07-15 22:49:36 +00:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
vec3 ecPosition = vec3(gl_ModelViewMatrix * gl_Vertex);
|
|
|
|
gl_Position = ftransform();
|
|
|
|
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
|
|
|
|
normal = gl_NormalMatrix * gl_Normal;
|
|
|
|
lightDir = normalize(vec3(gl_LightSource[0].position));
|
|
|
|
halfVector = normalize(gl_LightSource[0].halfVector.xyz);
|
|
|
|
diffuse = gl_Color * gl_LightSource[0].diffuse;
|
2009-11-17 06:23:21 +00:00
|
|
|
alpha = gl_Color.a;
|
2009-11-19 16:20:51 +00:00
|
|
|
constantColor = gl_FrontLightModelProduct.sceneColor
|
|
|
|
+ gl_FrontMaterial.ambient * gl_LightSource[0].ambient;
|
2009-07-15 22:49:36 +00:00
|
|
|
fogCoord = abs(ecPosition.z);
|
|
|
|
}
|