Vector through poly intersection...

Hi, after getting light mapping to work correctly, I looked at shadow mapping, and thought to myself, surely if I already have the location of each lumel, then perhaps I could do some collision detection to see if the lumel is obstructed by any of the polygons too to give a nice shadowing effect.

Does anyone know if this method is possible, and if so, how would i check to see if a line from a lumel to a single light intersects with a polygon.

Thanks in advance.


Hi :slight_smile:

“could do some collision detection to see if the lumel is obstructed by any of the polygons” it’s already happen with depth shadow map.
The problem is not the intersection himself but what the lumel represent.
Lumel is just a frustum of light or shadow who say: “my center is obstructed by a polygon” but we don’t know a this time what kind of polygon intersect and more precisely the edges of this polygon.
The shadow-edges are the most important information for a good shadow effect. Maximise this information it’s the way (not the only but a good :-)) to have a nice shadow rendering.


ps: sorry for my english :smiley:

I don’t really understand. I guess what I’m going have to end up doing is projecting a ray, and do some testing to see weather it intersects with any polygon in the scene, though I want to try and avoid full blown ray-tracing if possible.

Does anyone have any other ideas on the subject?


Please, if anyone else has any thoughts on the matter, I’d really appreciate it.


What you’re trying to do is some kind of shadow ray-tracer. It will be very slow. Shadow mapping is based on such thoughts but do not do it pixel per pixel. Instead it renders the scene from light view, then camera view, and do some comparisons to quickly know what fragments are lit or not.
Google “opengl shadow mapping” for example.

How about a more straight forward problem then, how would I tell if a face is looking at a light (perhaps even without knowing the winding order of the vertices)?

perhaps even without knowing the winding order of the vertices

Without a winding order, then you don’t know what the front of the face is. That effectively means that the face is always facing the light. Or that it is never facing the light. Or that the face doesn’t exist, because it has no orientation.

If you have a normal, then the face does have an orientation. And the test is simply N dot L: if this is negative, it’s facing away from the light.