Chapter 5, cone direction

It is confusing. Especially when we’re using position to calculate the direction.

Take a look at this picture, which I hope helps.

The light position (pink) is a positive direction. The cone direction is negative. To get them to point in the same direction, we have to negate one of them. Here I chose to negate the cone direction, but I could have negated the lightDirection instead, which probably would have been more “true”.

In that case, I’d have to negate the normal direction too, when calculating the diffuse intensity, which is also confusing! Consider the dot product result you want to achieve. Full intensity is where the dot product is 1.0. That’s when the two vectors point in the same direction. Intuitively, and in the chapter diagram, the direction vectors of the normal and the light direction point in different directions, which gives you a dot product of -1.0. However, to get full intensity of 1.0, you want the normal vector and the light direction vector pointing in the same direction.

I would suggest taking a look at the results in the shader debugger and drawing quick diagrams like the one I just did, to see what the directions actually are.

Once you can visualise the direction vectors, you can use whichever vector directions and dot products make most sense to you.

2 Likes