# Writing an optimized raytracing shadow solver

This topic is 2481 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm not after photorealism here, but would instead like to speed up my lightmapper for quasi-realtime application. The solution I'm thinking of is using occluder projection and floodfilling shadowed areas in a polygon's lightmap and finally computing distance/attenuation values for all texels that weren't occluded. However, I seem to be facing a bit of a brainfreeze with the projection bit.

The below image shows two cases where two faces (part of the little box) cast valid shadows onto the receiver's plane (which are then clipped to the receiver's shadowmap polygon) and a case where a face (the left blue line) casts a valid shadow, but is aligned in such a way that one or more of its vertices project to nowhere near the receiver's plane.

It's like I can understand the problem and part of the solution, but I'm unable to pinpoint it or write it down, particularly in 3D: how do I map projections that fail onto the receiver's plane to the appropriate min/max extent?

##### Share on other sites
Aighty, solved it by making the solution a tad bit more expensive, but still cheaper than raycasting. The algorithm now runs as follows:

1) calculate the world space corners of the lightmap
2) create 4 planes defining the light volume (a pyramid) from the light to the edges of the lightmap
3) clip all polygons (triangles really) against said planes
4) for each triangle the result is a convex polygon that is trivial to triangulate, but that maps precisely to the lightmap in world space after projection
5) convert the world space positions of the projected points to lightmap UV coords
6) fill the triangles in UV space

1. 1
2. 2
Rutin
21
3. 3
4. 4
A4L
15
5. 5
khawk
14

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633737
• Total Posts
3013612
×