Jump to content
  • entries
    943
  • comments
    5,899
  • views
    924,401

Double-buffered shadow maps


Josh

6,275 views

 Share

I got my idea working with spot lights! You can simply use a shadow mode of 2 to indicate an object or light should be considered "static". A light that has the static mode set will use two shadow maps; one for static objects and one for dynamic objects. In the image below, the walls and room are static, and the oildrum has the regular dynamic shadow mode set. As you can see, redrawing the shadow only requires 650 triangles. Without this feature, the whole room and everything in it would have to be redrawn any time something moved!

 

blogentry-1-12654158046432_thumb.jpg

Best of all, if the light moves or if any static object within the light's volume moves, both the static and dynamic shadowmaps are redrawn. The process is seamless for the end user. Dynamic lighting is usually dynamic, and baked lighting is usually static. I'm not sure what this qualifies as, but one thing is for sure...it's optimal!

 

This will yield a huge performance increase for scenes with lots of point and spot lights, as long as those lights remain in a fixed position. You should avoid having lots of moving point and spot lights.

 Share

21 Comments


Recommended Comments

Dynamic lighting is usually dynamic, and baked lighting is usually static. I'm not sure what this qualifies as

 

 

Dynaked lighting? :)

 

 

Great idea, nice one Josh :)

Link to comment

Normally you think of baked lighting as, you have a long processing step that is done before the game runs, then you display the results and it is fast. You think of dynamic lighting as, okay, it will be slow because it has to update each frame, but it looks good. It's interesting that our approach has turned into, "display the results each frame, and only update it when it is absolutely necessary".

Link to comment

Most probably the best feature of Leadwerks. No engine beats that. Love it, kills me that I don't a freaking second of time.

Awesome job!

Link to comment

Sorry, third comment but: Why not Directional Lights? I barely use point lights, I get everything from dir.

Link to comment

Directional lights usually have to be recalculated every single frame, because the camera is usually in motion. One technique I want to try with directional lights is one of those skewing techniques. They are glitchier than cascaded shadow maps, but if something with reasonable results can be implemented, it will only require one render of the scene, instead of the three that CSM requires.

Link to comment

@Josh: If it isn't too long to explain, how are Directional Lights different from the point lights in terms of camera movement? Unless it has to do with the actual positioning.

 

Wonders: Is it possible to glitch a point light with a distance and a radius so big it would practically act as a directional light? i.e. Sun-earth proportions.

Link to comment

No, you would not have enough video memory or texture bandwidth.

 

Directional lights are very specialized because you cannot possibly make a texture big enough to shade the whole scene, with a decent resolution. The whole challenge of directional lights is to use more pixels in the foreground and fewer in the background. The two main ways of doing this are to have several renders of the scene at different resolutions, or to render the shadow with a skewed matrix that uses more pixels closer to the camera.

 

There's little I can do to optimize directional lights, as they are very much a brute force technique. Far Cry 2 seems to use a skewing technique that doesn't seem to have visual errors, but of course they are going to go to great lengths to hide any errors their technique produces by not using certain sun angles. If I can devise a decent skewing technique, it could mean one shadow render of the scene instead of three, but I am not sure I have ever seen an error-free implementation.

 

..i guess, its still available option to turn off/on shadows from light source(point/spot) regardless this new approach taken..

Yes, but you have some additional options that will produce real time shadows at virtually no cost.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...