Screenspace Shadow Mapping Help!?

Started by
17 comments, last by FreneticPonE 9 years, 10 months ago


Found this siggraph crytek paper from last year. http://www.crytek.com/download/Playing%20with%20Real-Time%20Shadows.pdf

They are talking about shadows in general and there is a tiny little section about screen space self shadowing that seems to use this technique.
As a screen space technique it's not a drop-in replacement for regular shadow maps, really just an addon to increase fidelity.
I've implemented this by:

1) Implement SSAO biggrin.png the kind that uses random world/view-space points on a hemisphere/sphere around the pixel being shaded.

2) Take the code that finds sampling points on this (hemi)sphere, and change it to instead generate points along a line towards the light source.

Advertisement


"Efficient virtual shadow maps for many point lights" It's

I know this paper, it is still more theocrafting than practically useful (~15-20ms frametimes on NVIDIA GTX Titan GPU + Intel Core i7-3930K CPU isn't awesome for games yet). I've hoped for a more pratically useful solution, we will see what useful changes happens once the new API approaches/consoles kicks in.

Screen Space shadowing is like screen space reflections , but here you trace a vector pointing to light. if the z of your ray is less than the depth buffer you have a hit and means shadow. This algorithm produce artifacts when shadow casting objects are not present at screen space.

For shadow maps I believe you can create a priority system . Let's say your engine decides to have 20 shadow casting lights . So choose 20 of your lights that has the greatest effect .(Near the camera , Bigger Radius , ...). And also with the help of geometry shaders you can produce a cube map with one render pass.

Thank you all for the posts. All of these are great suggestions and I certainly will ensure telanor takes a look at them. I think one of the hardest parts about shadows and our system is that we have a fully dynamic world. Most of the tricks of the trade are not able to be produced in our setup without creating some serious issues. I will keep this post in mind though. Any other suggestions or ideas would be greatly appreciated.

For point lights, stencil shadows are very effective, but they are very hard to implement though. You will even need the casting geometry be extrudable and an enclosed mesh. But they are suitable for deffered illumination.

We also have fully dynamic scenes and lots of pointlights but their shadows are not that important so we use screenspace raytracing. It's really simple to implement and its scale quite well. Quality is lot better than having no shadow solution for all lights. I should try to combine this with some screen space directional oclusion.

Would you be willing to share how you did it? Or even work with Telanor directly? PM Him on the forum if you would please and maybe we can hook something up. Thank you very much

Would you be willing to share how you did it? Or even work with Telanor directly? PM Him on the forum if you would please and maybe we can hook something up. Thank you very much

I can give the code but I can't give any support for while. My weddings tomorrow and at summer vacation for couple weeks for now.


float3 screenSpacePos = float3(input.position.xy  * u_invFrameBufferSize, clipSpaceZ);
 
float3 rayPos = u_lightPositionProjected; // xy in texture space. z in clip space
float3 rayDir = screenSpacePos - rayPos;
 
int samples = 22;                                              
rayDir /= samples;
                                       
float jitter = -0.5 * ((screenUV.x+screenUV.y) & 1); // help with aliasing
rayPos += rayDir * jitter;
float occluded = 0;                                    
float2 treshold = float2(0.0002, 0.003); // tune
[unroll]
for (int i = 0; i < samples; i++)
{
        rayPos += rayDir;
        float4 d = 1.0 - rcp(rayPos.z) * u_texture0.Gather(samData, rayPos.xy); // texture is downsampled 16-bit depth buffer 
        occluded += dot(step(treshold.x, d), step(d, treshold.y));
}
light *= pow(0.93, occluded); // exponential fallof

Occlusion test should work better if I would use viewSpace relative test instead of clipspace relative.


"Efficient virtual shadow maps for many point lights" It's

I know this paper, it is still more theocrafting than practically useful (~15-20ms frametimes on NVIDIA GTX Titan GPU + Intel Core i7-3930K CPU isn't awesome for games yet). I've hoped for a more pratically useful solution, we will see what useful changes happens once the new API approaches/consoles kicks in.

Found that with shadow map caching it can work well for many dozens of lights. But indeed while hundreds may "possible" it's not practical on most systems. And you need all the overhead of the culling scheme, which is great if you're targeting hundreds of point lights to begin with. But we're still a long way off from having a city scene with hundreds of proper point lights, and I suspect that will just have to be brute forced one way or another.

This topic is closed to new replies.

Advertisement