Hi,
I’ve got a cgprogram shader that I’m attaching to a projector. Ultimately this is to achieve a specific shader driven lighting effect. I want to do the appropriate dot(N,L) diffuse term that you would typically do with a light, only instead I want to use the forward vector of the projector as L.
I’m attempting to do this by putting a ‘forward’ vector into _Projector space - a la:
float3 projectorForward = normalize(mul(_Projector,float4(0,0,1,1)).xyz);
The reason I’m choosing (0,0,1) is because the projector’s forward axis seems to be down its local +z in unity.
The problem I’m running into is I can’t seem to figure out how to get this back into world space - it seems I have no access to the inverse matrix for _Projector. If I did, I would be trying to compute the world space forward axis vector, and dot that with my IN.worldNormal vector.
First off, does this sound like the right thing to do? And if so - does anyone have any ideas how I can get there efficiently? I don’t want to have to compute the inverse matrix by hand.