Can you mathematically find NdotL knowing only NdotV and NdotH ?

I know this is a little odd question but is it possible to correctly find the value of NdotL knowing the other two ? :twisted:

How did you get NH without the light vector?

I’m not calculating this inside the shader, I’ve already said that is a odd question, that’s why I’m asking about dot products, not vectors themselves.

Also you can reverse the problem, can you calculate NdotH knowing the NdotE NdotL float values ?

You can’t… its like saying: I have a ball thats moving with constant velocity and direction and a pole. I know it was 2 metres away from the pole a second ago and now it’s 1 metre. How close will it be a second later? You can’t know. It could be touching the pole or it could be 2 metres away again, depending on the actual trajectory. Knowing the distance is not enough. The same principle applies here… dot product is basically an angular distance. If you have NdotV and NdotH and want to know NdotL, knowing the relationship between the positions is not going to help you.

I asked because on another forum I saw it written like so:

half NdotH = (NdotL+NdotE) / hDirLength;

Then:
NDotL = NdotH/hDirLength - NdotE;

By doing some tests I thinks it’s not correct, though.

Yeah… NdotL = normalize(NdotH - NdotV) would work only if all three of the vectors lie on the same plane.

Yes, thanks for confirming this.

Mhm…I’d guessed it’s possible.

A dot product is basically the cos of the angle between the two vectors.

So doing acos(NdotV) gives the angle between N and V.

You’re looking for the angle between N and L.

this is a good image: http://i.stack.imgur.com/wXKW3.gif

To find the angle between V and H, calculate acos(NdotV) - acos(NdotH)
the Angle between V and L is twice as big as the angle between V and H (that’s why it’s called half vector)
To get the angle between N and L, subtract acos(NdotH)

so: NdotL = cos(acos(NdotV) - 2 * acos(NdotH))

I’m pretty sure I made a mistake somewhere though :slight_smile:
Still worth a try though.

I will try out of curiosity, thanks.