Original Post
Here''s the situation: I have my lightmap engine working perfectly, but only in static form, what I want to do now is project a ligtmap onto a surface coming from a dynamic source (ie.: a bolt of fiery plasma or the twinkle of a torch being transported
)
What I know so far: You can find where to draw the texture by projecting onto the plane (orthogonally) containing the desired polygon(s), align it by using the plane''s normal and size it by using the distance (am I right so far?)
The problem is trying to get the texture coordinates for the lightmap on that polygon, it can be:
-Totally outside (don''t draw anything)
-Partially (or totally) inside (calculate s and t for the lightmap)
The problem is finding out those texture coordinates, how do you go about translating it to s and t for a 3-sided polygon?
So far I tried just using glDepthFunc(GL_EQUAL) and crossed my fingers hoping that it would not draw anything outside the polygon and clip it automatically, well, it sorta works, but this causes some "z-fighting" and it is hardly optimized...
Anyone can fill me in on the technique?
Thanks