I'm working a spotlight for my deferred renderer and I'm having trouble with matching the mesh to the visual representation of the light. Right now my mesh is a cone, the apex of the cone is at (0,0,0), it has a height of 1 and a radius of 1. The direction of this cone is (0,-1,0) when the rotation is (0,0,0).
The relevant GLSL code:
float spot_alpha = dot(-l,normalize(vec3(0,-1,0) )); // <------ float inner_alpha = cos(light.falloff); float outer_alpha = cos(light.radius); float spot = clamp((spot_alpha - outer_alpha) / (inner_alpha - outer_alpha),0.,1.);
As you can see, the GLSL code uses a direction to define the area to be lit, so I could get this direction as a uniform, but I would need to find a rotation from that for the mesh to follow, or I can get the rotation and find a direction, but I don't know how to do either of these things.
Can I rotate a direction? How do I do it? If I can't, is there another solution for this problem?