Arath,
Is it me, or are you looking for the light’s direction, not the position? Instead of
MOV oColor.xyz, light_dir;
You would want something like
ADD oColor.xyz, light_dir, -v[0];
And of course you would want the color to be normalized and range compressed, but you get the idea. I don’t think that state.light[0].position is really the ‘lightDir’ you want it to be. Observe the light state table…
Light Property Bindings
Binding Components Underlying State
----------------------------- ---------- ----------------------------
state.light[n].ambient (r,g,b,a) light n ambient color
state.light[n].diffuse (r,g,b,a) light n diffuse color
state.light[n].specular (r,g,b,a) light n specular color
[b]state.light[n].position (x,y,z,w) light n position[/b]
…
Now here is what is extremely confusing, take a look at (73) …
…
PARAM lightDir = state.light[0].position;
…
Compute diffuse and specular dot products and use LIT to compute
lighting coefficients.
DP3 dots.x, xfNormal, lightDir;
DP3 dots.y, xfNormal, halfDir;
MOV dots.w, specExp.x;
LIT dots, dots;
My 2 cents are
A - According to the light properties, ‘lightDir’ is not the light’s direction, it is it’s position, so why isn’t there a/an ADD/SUB command and an accompanying normalization of the vector?
B - I believe state.light[i].position is stored in eye space because in that example shader, ‘lightDir’ is not modified by any matricies.
Dan
[This message has been edited by Dan82181 (edited 09-22-2002).]