##
[EDIT] I tried this shader pair out in ShaderDesigner with all lights disable and it worked. Any suggestions on what I might be doing wrong?

CD

I am trying to write a shader which calculates a quantity of reflected light from a source. Sounds simple enough, but I am having problems with it…

Here are my assumptions:

1 - The source location and view point are the same. That is, the viewer is observing the amount of light reflected back to his position, which is also the origin of the light.

2 - I know the broadband reflectance of a material as a function of incidence angle and view angle. That is, for some discrete angles, I know brdf(in, out) = blah blah blah.

I use a GL light to mimic the source.

```
glEnable(GL_LIGHTING);
float lightPosition[4] = {m_source->m_WorldPos[0], m_source->m_WorldPos[1], m_source->m_WorldPos[2], 0.0f};
glLightfv( GL_LIGHT0, GL_POSITION, lightPosition ); // This sets our light position
```

To begin with I would just be happy to set the fragment color to the dot of the vertex normal and light direction, but I can’t seem to get that to work (which is all I am trying to do with the code below)…

This is my vert shader

```
varying vec3 normal,lightDir;
varying float NdotL;
varying float LdotN;
void main()
{
vec4 ecPosition;
vec3 aux;
// first transform the normal into eye space and normalize the result
normal = normalize(gl_NormalMatrix * gl_Normal);
// transform vertex to eye space, normalize result
ecPosition = normalize(gl_ModelViewMatrix * gl_Vertex);
aux = vec3(gl_LightSource[0].position-ecPosition);
lightDir = normalize(aux);
NdotL = dot(normal, lightDir);
LdotN = dot(lightDir, normal);
gl_Position = ftransform();
}
```

Here is my frag shader…

```
varying vec3 normal,lightDir;
varying float NdotL;
varying float LdotN;
void main()
{
float value = 1.0;
if (NdotL > 0.0) {
value = pow(NdotL, 3);
}
gl_FragColor = vec4(value, value, value, 0.0);
}
```

The problem I see is that NdotL is constant, even though the object I am rendering is a cylinder. I would have thought it would roll off at the edges… Also the cylinder is pitching and yawing, so I would have thought I would see some change as it moves, but no change.

What am I doing wrong?

CD