View Full Version : Ambient lighting VP (should be easy)

07-08-2003, 05:03 AM
The only thing I do in my vertex program is:
MOV result.color, state.lightprod[0].ambient;
The light has everything but ambient disabled. It should look as the fixed function lighting, but differs some.. What's wrong?
Edit - I've tried MUL result.color, state.lightprod[0].ambient, state.lightmodel.ambient;
It just went black...

[This message has been edited by dbugger (edited 07-08-2003).]

07-08-2003, 06:02 AM
What do you mean looks different? How different? A screenshot of FFP versus VP?

07-08-2003, 06:12 AM
If you disable a light, it doesn't provide any ambient term.

07-08-2003, 07:33 AM
I guess the fixed function lighting is brighter? In that case you forgot that the global ambient lighting term (provided with glLightModel() ) adds (0.1, 0.1, 0.1) to your ambient illumination by default.

07-08-2003, 07:52 AM
state.lightprod[0].ambient is a binding corresponding to the product of the ambient light and the ambient material values. Have you ensured your material ambient is correct as well as your light ambient?

07-08-2003, 08:42 AM
Light model ambient should be added, not multiplied.

07-08-2003, 09:46 PM
Thanks for your replies!!! Yes the ambient artifacts are due to the global ambient light, but it didn't help adding it, it becomes way to bright. How should I include it? I now also got a problem with diffuse, it's to bright. v-mans demo "very basic vp" shows the same artifacts: http://www.geocities.com/vmelkon/verybasicvp.html

07-08-2003, 10:31 PM
Solved the ambient! Had to add the scenecolor instead of the global ambient...
But why is diffuse so bright?

07-08-2003, 11:15 PM
you should normalize your normals and light-vector.
(i'm not really shure about light-vector)

07-08-2003, 11:24 PM
Oh no!! Stupid me... You're absolutely right, I forgot to normalize the normals! Thanx alot gvm, saved my day http://www.opengl.org/discussion_boards/ubb/smile.gif

07-09-2003, 12:10 AM
One more thing.. Attenuation should only affect the light[x].ambient(+dif+spec) so I can't use lightprod[x].ambient, right???

07-09-2003, 12:33 AM
Wrong! But it still doesn't work.. I think I'll have to rewrite my attenuation-code a little. If anyone has done attenuation in vp, please share..

07-09-2003, 12:54 AM
is ambinet lighting attenuate???
i'm shure that diffuse is, but ambient always same evrywhere.

try to look at developer.nvidia.com for papers
there was an example about doint lighting in vertex programs(diff+spec) (but that was for nv_vp, not for arb_vp. i think it will be easy to convert it to arb version)

07-09-2003, 01:24 AM
According to the red book ambient, diffuse and specular terms should be attenuated, only emissive and global ambient should be left. Thanks for the tip, but I've already searched everywhere, and there's not a single example that covers everything and is correct.. http://www.opengl.org/discussion_boards/ubb/frown.gif

07-09-2003, 02:12 AM
Thanks all for your help! Everything seems to be ok now. http://www.opengl.org/discussion_boards/ubb/smile.gif

07-09-2003, 05:37 AM
Oh yes, nice catch with the global ambient thing. Looks like I didnt take my own advice.