Hi everyone, I am writing my own PBR shader that uses physic lights, so it needs range, direction and angle of spot lights. I have get the range and angle by some trick, but has no idea that how to get direction:
For a spotlight, the unity_WorldToLight matrix is a transform and perspective matrix, which makes things a little funny. However you’re pretty close already:
For an orthogonal matrix, the transpose and the inverse are the same, and doing the mul in vector matrix order applies the matrix as transposed vs matrix vector order. This only works because the forward axis of the matrix isn’t affected by the perspective, but it does work.