Dot about Light source and point

Hello caroline,

This week I review code and I have a new question in chapter 5. In The dot product section, may I think when the light vector and point normal vector are parallel but opposite directions, it would be the brightest at point?

1 Like

In this chapter, yes when the normalized dot product is -1, then the light will be brightest.

This thread might help: Chapter 5, cone direction

Remember that you can return just the dot product converted into a float4 from the shader to visualize what value it has.

I see, but would you please tell me the reason why need to negate one normal direction(sunlight normal) to let they are the same direction.
May I think it is only for computing the color value?

Everything that happens in the fragment shader is simply for computing the color of that fragment.

You should have full brightness when the dot product is 1.0. When the dot product of two vectors equals 1.0, that means the two vectors are pointing in the same direction.

However, imagine that you have a light pointing down on a normal, and that normal is pointing at the light, you would expect that to be full brightness. But the dot product of those two vectors would be -1.0.

If you negate one direction vector, then when you compare the two vectors, the dot product would be 1.0, achieving full brightness.

1 Like