Jump to content

  • Log In with Google      Sign In   
  • Create Account


Screenspace Shadow Mapping Help!?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
18 replies to this topic

#1 riuthamus   Moderators   -  Reputation: 4852

Like
0Likes
Like

Posted 05 June 2014 - 01:51 PM

Done a few searches but found no relevant tutorials ( according to telanor ) about how to setup screenspace shadow mapping. Our current setup cascaded shadow mapping has some issues with point lights and models. I would like to create a less expensive method that provides us with decent results. Any and all help would be appreciated.



Sponsor:

#2 Madhed   Crossbones+   -  Reputation: 2791

Like
1Likes
Like

Posted 05 June 2014 - 03:35 PM

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 can imagine it working pretty well for range restricted point lights though.

 

Are you using deferred lighting? Then it should be a pretty straight forward to incorporate the tracing into the rendering of the point light polygons.



#3 riuthamus   Moderators   -  Reputation: 4852

Like
0Likes
Like

Posted 05 June 2014 - 03:52 PM

We are using deferred rendering. Right now Telanor has chosen to use cube map shadow mapping for the point lights ( creating a big issue with peformance ). I can have him post here to explain his choice and maybe that will give way to what we should be doing and how. Thanks in advance.



#4 Madhed   Crossbones+   -  Reputation: 2791

Like
0Likes
Like

Posted 05 June 2014 - 04:12 PM

Actually it's not a shadow mapping algorithm but rather a ray tracer.

 

Trace the ray from the pixel towards the light source, if the sampled depth is lower than the interpolated depth of the ray than that original pixel must be occluded.


Edited by Madhed, 05 June 2014 - 04:52 PM.


#5 slicer4ever   Crossbones+   -  Reputation: 3499

Like
1Likes
Like

Posted 05 June 2014 - 04:14 PM



We are using deferred rendering. Right now Telanor has chosen to use cube map shadow mapping for the point lights ( creating a big issue with peformance ). I can have him post here to explain his choice and maybe that will give way to what we should be doing and how. Thanks in advance.

their's also hemispherical shadow mapping that reduces a cube shadow map down to 1 texture(or 2 for both sides).  http://www.thomasannen.com/pub/cgi2002.pdf this is a paper i tried to follow to get it to work when i was experimenting with it, but i never got it working.


Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

#6 riuthamus   Moderators   -  Reputation: 4852

Like
0Likes
Like

Posted 05 June 2014 - 04:20 PM

I think that is where telanor got stuck as well, not sure... he said he did it some time ago. I noticed our shadows were not working for point ligths and brought it up. He seems to be content but I am not. Hence we are here



#7 Ashaman73   Crossbones+   -  Reputation: 7126

Like
1Likes
Like

Posted 05 June 2014 - 11:00 PM


Right now Telanor has chosen to use cube map shadow mapping for the point lights ( creating a big issue with peformance ).

That is the way to go:

add cube map shadow mapping for point lights

-> be happy about how cool it looks 

-> add more lights

-> see how bad the performance go

-> remove pointlights smile.png

 

To be honest, point light shadows are really extremely expensive, all shadow mapping variances are just too expensive to handle more than a handful of lights. One major issue is, that you need to render the scene multiple times which kills your performance by too many batches (this might change with new API approaches AZDO [Approach Zero Driver Overhead], Mantle,DirectX12), but for now shadow mapping is really,really expensive and real screen-space shadow mapping does not exist in any general, acceptable way.

 

The most common workaround:

1. use only point light shadows , if it is really necessary (even paraboloid shadow mapping), e.g. one major gameplay feature use one pointlight shadow

2. use shadow mapping for the most important light sources only (sun/moon plus some major light sources).


Edited by Ashaman73, 05 June 2014 - 11:42 PM.


#8 Frenetic Pony   Members   -  Reputation: 1277

Like
0Likes
Like

Posted 05 June 2014 - 11:19 PM

 


Right now Telanor has chosen to use cube map shadow mapping for the point lights ( creating a big issue with peformance ).

That is the way to go:

add cube map shadow mapping for point lights

-> be happy about how cool it looks 

-> add more lights

-> see how bad the performance go

-> remove pointlights smile.png

 

To be honest, point light shadows are really extremely expensive, all shadow mapping variances are just too expensive to handle more than a handful of lights. One major issue is, that you need to render the scene multiple times which kills your performance by too many batches (this might change with new API approaches AZOD, Mantle,DirectX12), but for now shadow mapping is really,really expensive and real screen-space shadow mapping does not exist in any general, acceptable way.

 

The most common workaround:

1. use only point light shadows , if it is really necessary (even paraboloid shadow mapping), e.g. one major gameplay feature use one pointlight shadow

2. use shadow mapping for the most important light sources only (sun/moon plus some major light sources).

 

 

Nah, do enough work and you can get hundreds of point light shadows in the same scene. Culling is really a key, and not doing work when not necessary. Shadow map caching can do wonders for reducing everything from bandwidth to draw calls.

 

It's all a lot of work though, well documented work, but a lot of it. CSM scrolling has a basic overview for both point lights and a directional light: http://advances.realtimerendering.com/s2012/insomniac/Acton-CSM_Scrolling(Siggraph2012).pdf the basic idea is to check whether each light has a moving object inside its influence and then only the changes necessary, which should be a handful of objects if the point light is stationary and so is most of its environment.


Edited by Frenetic Pony, 05 June 2014 - 11:23 PM.


#9 Ashaman73   Crossbones+   -  Reputation: 7126

Like
2Likes
Like

Posted 05 June 2014 - 11:34 PM


you can get hundreds of point light shadows in the same scene.

Ahh cool, can you point me to some demo, game or presentation which managed this, especially the hundreds part sound really interesting, I'm not interest in caching single shadow maps, but multiple, point light shadow maps, because my game would profit from such a feature too.



#10 Frenetic Pony   Members   -  Reputation: 1277

Like
1Likes
Like

Posted 06 June 2014 - 12:33 AM

"Efficient virtual shadow maps for many point lights" It's basically an extension of clustered shading to also allow culling for shadow mapping, along with a few hacks (the "virtual" part) for the maps themselves.

 

So if you've already got clustered deferred/forward going on your halfway there, which is nice.



#11 Hodgman   Moderators   -  Reputation: 29514

Like
3Likes
Like

Posted 06 June 2014 - 12:38 AM


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.



#12 Ashaman73   Crossbones+   -  Reputation: 7126

Like
1Likes
Like

Posted 06 June 2014 - 12:56 AM


"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.



#13 BlackBrain   Members   -  Reputation: 314

Like
1Likes
Like

Posted 06 June 2014 - 05:55 AM

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.



#14 riuthamus   Moderators   -  Reputation: 4852

Like
0Likes
Like

Posted 06 June 2014 - 07:00 AM

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.



#15 JohnnyCode   Members   -  Reputation: 231

Like
0Likes
Like

Posted 06 June 2014 - 07:19 AM

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.



#16 kalle_h   Members   -  Reputation: 1342

Like
3Likes
Like

Posted 06 June 2014 - 12:31 PM

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.



#17 riuthamus   Moderators   -  Reputation: 4852

Like
0Likes
Like

Posted 06 June 2014 - 12:38 PM

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


Edited by riuthamus, 06 June 2014 - 01:06 PM.


#18 kalle_h   Members   -  Reputation: 1342

Like
7Likes
Like

Posted 06 June 2014 - 02:31 PM

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.



#19 Frenetic Pony   Members   -  Reputation: 1277

Like
1Likes
Like

Posted 06 June 2014 - 04:13 PM

 


"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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS