Ambient lighting VP (should be easy)

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).]

What do you mean looks different? How different? A screenshot of FFP versus VP?

If you disable a light, it doesn’t provide any ambient term.

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.

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?

Light model ambient should be added, not multiplied.

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:

Solved the ambient! Had to add the scenecolor instead of the global ambient…
But why is diffuse so bright?

you should normalize your normals and light-vector.
(i’m not really shure about light-vector)

Oh no!! Stupid me… You’re absolutely right, I forgot to normalize the normals! Thanx alot gvm, saved my day

One more thing… Attenuation should only affect the light[x].ambient(+dif+spec) so I can’t use lightprod[x].ambient, right???

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…

is ambinet lighting attenuate???
i’m shure that diffuse is, but ambient always same evrywhere.

try to look at 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)

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…

Thanks all for your help! Everything seems to be ok now.

Oh yes, nice catch with the global ambient thing. Looks like I didnt take my own advice.