Using a 2D Texture for Point-Light Shadows

Started by
19 comments, last by agleed 9 years, 1 month ago

I once used projections on 4 sides tetrahedron for my shadow mapping needs (one shadow map for all cases for simplicity reasons).

This, of course, requires 4 projection matrices that target specific part of the texture + clipping planes. PCF works if you use rays (and dinamically determine which triangle is affected). Hope this helps.

Advertisement

Why not use two parabolic shadow maps for point lights? You can use the filtering methods you would normally be able to use for directional shadows.

http://graphicsrunner.blogspot.com/2008/07/dual-paraboloid-shadow-maps.html

I imagine you might even be able to render to it with one pass using a geometry shader too.

Thoughts?

PCF filtering over dual paraboloids is non-trivial to say the least. Although the curvature of the results could yield softening with fewer block-shaped artifacts (Poisson sampling is often used to get around this), the density of the pixels changes depending on how far away from the center you are, so you would effectively be sampling close-together shadow points near the center and farther-away points near the edges.

Ultimately I was wrong about the type of filtering we wanted to do to the shadows—we did at one point want to use anti-aliasing with VSM shadows, but because of the large gap between our near and far planes there were too many artifacts.

We are sticking to PCF, which has hardware support for blending 4 shadow samples at a time but we need more than that.

Since this is a run-time sampling set we need to be able to manually sample left, right, up, and down from the center texel, so we need to sample into the cube texture manually. Otherwise we would need to calculate in spherical coordinates where the neighboring texels are which would be incredibly slow, especially since PlayStation 4 and Xbox One have intrinsics to calculate where to sample on cube textures. Sampling a cube texture natively outputs these same intrinsics once for each sample, whereas by manually using the intrinsics we can reuse their results and create the absolute minimal code for the multiple samples we need.

Simply drawing the cube texture’s faces to a single 2D texture would not help reduce this complexity, but it helps us shift towards texture atlases for shadows which will in the end allow us to apply all the shadows in our scene in one pass.

L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Ultimately I was wrong about the type of filtering we wanted to do to the shadows—we did at one point want to use anti-aliasing with VSM shadows, but because of the large gap between our near and far planes there were too many artifacts.

You can try MSM shadow mapping which is the last tech on variance shadow mapping. But it still have bleeding on certains cases.

Simply drawing the cube texture’s faces to a single 2D texture would not help reduce this complexity, but it helps us shift towards texture atlases for shadows which will in the end allow us to apply all the shadows in our scene in one pass.

You will render all shadow map in a texture2D atlas, uses it to draw deferred shadow using a fullscreen quad then render deferred lighting on it ?

You can try MSM shadow mapping which is the last tech on variance shadow mapping. But it still have bleeding on certains cases.

My coworker showed me a video on it yesterday. That will be a goal for the future. According to the video he showed me, PCF was running at 400 FPS and MSM was running at 500-550 (and with fewer artifacts). That’s a separate task I will propose in the future.


You will render all shadow map in a texture2D atlas, uses it to draw deferred shadow using a fullscreen quad then render deferred lighting on it ?

Our current implementation has to make 2 passes to render shadowed lights (and my description of it may be wrong—I only know roughly how that part of the engine works): One to apply shadows to the stencil buffer and then again to add lighting. Yes, deferred. Yes, we will be able to merge all of the shadows into the same pass as lighting if all the shadows are in a single texture.

Even in forward rendering this would be a huge benefit. Typical implementations use one pass per shadow also, and in that case you have to submit all the geometry again for each pass.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid


My coworker showed me a video on it yesterday. That will be a goal for the future. According to the video he showed me, PCF was running at 400 FPS and MSM was running at 500-550 (and with fewer artifacts). That’s a separate task I will propose in the future.

According to MJP, moving to MSM is very straightforward, should not take long time.

According to MJP, moving to MSM is very straightforward, should not take long time.

That’s fine.
I will bring it up in the future, when we’ve stabilized the current set of changes and are ready for the next set of optimizations.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

There's an upcoming article on this topic in GPU Pro 6 btw: http://hd-prg.com/tileBasedShadows.html

(Code included...if you want to dig into that)

"Some people use Singletons, some people are Simpletons." - Bill Gates
"Yum yum, I luv Cinnabon." - Mahatma Gandhi

There's an upcoming article on this topic in GPU Pro 6 btw: http://hd-prg.com/tileBasedShadows.html

(Code included...if you want to dig into that)

Looks very interesting. Would be nice to see a comparison between this and http://www.cse.chalmers.se/~olaolss/main_frame.php?contents=publication&id=clustered_with_shadows_siggraph_2014

There's an upcoming article on this topic in GPU Pro 6 btw: http://hd-prg.com/tileBasedShadows.html
(Code included...if you want to dig into that)


Looks very interesting. Would be nice to see a comparison between this and http://www.cse.chalmers.se/~olaolss/main_frame.php?contents=publication&id=clustered_with_shadows_siggraph_2014

My coworker and a guy from AMD are going to release a paper soon which I is a significant improvement on—I believe—this. Many times higher quality and many times faster.
I can’t say much about it right now, except you’d be better waiting for it (assuming I am correct that this is the technique it is replacing) than implementing this.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

This topic is closed to new replies.

Advertisement