Jump to content
  • Advertisement
Sign in to follow this  
irreversible

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!