Jump to content

  • Log In with Google      Sign In   
  • Create Account


need to reduce shadow mapping aliasing


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
12 replies to this topic

#1 Yours3!f   Members   -  Reputation: 1300

Like
0Likes
Like

Posted 04 March 2013 - 03:06 PM

Hi,

 

I've implemented the "screen space soft shadows" technique (in OGL):

[Gumbau] Jesus Gumbau, Miguel Chover, and Mateu Sbert, “Screen-Space Soft Shadows”, GPU Pro, pp. 477 – 490

 

The shadow looks nice and soft, however making the shadow soft didn't remove the blockiness. I found out that this can be reduced by increasing the shadow map size from  1024 to 2048 ( and so on ), but this kills performance, and memory bandwith. Is there some kind of filtering technique that can reduce this basic blocky property of shadow mapping? So that soft shadows can really look soft. Not blocky soft :)

 

I've attached a picture with soft shadows turned up, and of the simple shadow map.

 

Best regards,

Yours3lf

Attached Thumbnails

  • shadow_alias.png
  • shadow_alias_wo_blur.png


Sponsor:

#2 ATEFred   Members   -  Reputation: 1055

Like
1Likes
Like

Posted 04 March 2013 - 03:31 PM

Options would include cascaded shadow maps, tiled shadow maps for using different shadow maps for different slices / areas of your scene to maximize resolution, or trapezoidal or perspective shadow maps to change the projection to maximize resolution close to the camera. 



#3 Frenetic Pony   Members   -  Reputation: 1277

Like
2Likes
Like

Posted 04 March 2013 - 04:38 PM

Depends entirely on what you're doing.

 

Is it a point light or directional? Either way there's multi sampling the shadow map is going to improve it, but is going to take up much the same performance hit as just increasing shadow maps size. There's also temporal anti aliasing. The idea being you slightly shift the projection of the shadow map each frame, keeping the last frames results to combine with the new ones. It's basically multi sampling over time, but has issues with moving objects.

 

If it's just a directional shadow, say from the sun, then things get a bit easier. Cascaded shadow maps use multiple shadow maps projected towards the sun, in a neat kind of shadow LOD trick. http://developer.download.nvidia.com/SDK/10.5/opengl/src/cascaded_shadow_maps/doc/cascaded_shadow_maps.pdf There's also a much more advanced version of this this that I have bookmarked somewhere, and I can't remember the name of. Regardless it advances on cascaded shadow maps to the point where you can get results that are basically alias free.

 

Anyway, hope that helps.



#4 Promit   Moderators   -  Reputation: 6636

Like
2Likes
Like

Posted 04 March 2013 - 07:19 PM

There are much less extreme options to try before doing what's suggested above. The key is to fit the shadow frustum as close as possible to the view frustum and shadow casters onto that frustum. Get your Z depth as tight as you can, boost the shadow precision if you can, make the shadow area smaller if you can. Try centering the shadow in front of the camera. Explore Z precision tricks like reversed depth planes.

 

That said, I haven't tested screen-space soft shadows yet but this might be an intrinsic part of blurring in what is basically the wrong domain.

 

Depends entirely on what you're doing.

 

Is it a point light or directional? Either way there's multi sampling the shadow map is going to improve it, but is going to take up much the same performance hit as just increasing shadow maps size. There's also temporal anti aliasing. The idea being you slightly shift the projection of the shadow map each frame, keeping the last frames results to combine with the new ones. It's basically multi sampling over time, but has issues with moving objects.

 

If it's just a directional shadow, say from the sun, then things get a bit easier. Cascaded shadow maps use multiple shadow maps projected towards the sun, in a neat kind of shadow LOD trick. http://developer.download.nvidia.com/SDK/10.5/opengl/src/cascaded_shadow_maps/doc/cascaded_shadow_maps.pdf There's also a much more advanced version of this this that I have bookmarked somewhere, and I can't remember the name of. Regardless it advances on cascaded shadow maps to the point where you can get results that are basically alias free.

 

Anyway, hope that helps.

SDSM?

http://visual-computing.intel-research.net/art/publications/sdsm/

 

PS Holy shit this text editor we've got nowadays is a piece of trash


Edited by Promit, 04 March 2013 - 07:19 PM.


#5 Yours3!f   Members   -  Reputation: 1300

Like
0Likes
Like

Posted 05 March 2013 - 03:27 AM

Depends entirely on what you're doing.

 

Is it a point light or directional? Either way there's multi sampling the shadow map is going to improve it, but is going to take up much the same performance hit as just increasing shadow maps size. There's also temporal anti aliasing. The idea being you slightly shift the projection of the shadow map each frame, keeping the last frames results to combine with the new ones. It's basically multi sampling over time, but has issues with moving objects.

 

If it's just a directional shadow, say from the sun, then things get a bit easier. Cascaded shadow maps use multiple shadow maps projected towards the sun, in a neat kind of shadow LOD trick. http://developer.download.nvidia.com/SDK/10.5/opengl/src/cascaded_shadow_maps/doc/cascaded_shadow_maps.pdf There's also a much more advanced version of this this that I have bookmarked somewhere, and I can't remember the name of. Regardless it advances on cascaded shadow maps to the point where you can get results that are basically alias free.

 

Anyway, hope that helps.

 

 

It is a spot light, located at (0, 5, -5), looking 20 degrees downwards. It lights a box of size 2x2 units, located at (0, 0, -8). So this is a really up-close shot.

So multi sampling is not an option.... That's sad. I don't want to go in the temporal direction as, I didn't go with it when doing SMAA and other stuff. I it when the scene remains sharp even in motion. I think it is important to preserve sharp percieving of the players especially in a fast shooting situation.

 

I know about the csm and pssm methods for direction lights, but this is for spot/point lights.



#6 Yours3!f   Members   -  Reputation: 1300

Like
0Likes
Like

Posted 05 March 2013 - 03:28 AM

Options would include cascaded shadow maps, tiled shadow maps for using different shadow maps for different slices / areas of your scene to maximize resolution, or trapezoidal or perspective shadow maps to change the projection to maximize resolution close to the camera. 

 

Thanks for the reply, I'm doing perspective projection for the spot light shadow map. I use 45 degree fov.



#7 Yours3!f   Members   -  Reputation: 1300

Like
0Likes
Like

Posted 05 March 2013 - 03:34 AM

There are much less extreme options to try before doing what's suggested above. The key is to fit the shadow frustum as close as possible to the view frustum and shadow casters onto that frustum. Get your Z depth as tight as you can, boost the shadow precision if you can, make the shadow area smaller if you can. Try centering the shadow in front of the camera. Explore Z precision tricks like reversed depth planes.

 

That said, I haven't tested screen-space soft shadows yet but this might be an intrinsic part of blurring in what is basically the wrong domain.


SDSM?

http://visual-computing.intel-research.net/art/publications/sdsm/

 

PS Holy shit this text editor we've got nowadays is a piece of trash

 

I know about the z-depth trick, and I experimented with it but at this close distance it didn't really improve much.

 

"The key is to fit the shadow frustum as close as possible to the view frustum and shadow casters onto that frustum."

is there a paper / tutorial on this?

 

"That said, I haven't tested screen-space soft shadows yet but this might
be an intrinsic part of blurring in what is basically the wrong domain."

yeah this is really annoying as one might expect such a strong blur to erase such artifacts.

 

agreed it sucks biggrin.png

 

EDIT:

today I experimented with the shadow mapping setup, I added checking sampling outside the shadow frustum.

I also played around with the perspective projection: I changed the range from (1, 50), to (5, 25). This drastically reduced the aliasing at the same shadow map resolution.

So I think it may be really important to get the near far planes right to squeeze out as much precision out of the available texture space as possible.


Edited by Yours3!f, 05 March 2013 - 05:01 PM.


#8 Styves   Members   -  Reputation: 1000

Like
1Likes
Like

Posted 05 March 2013 - 09:17 AM

Try using randomly jittered samples, à la Crysis (http://i246.photobucket.com/albums/gg90/desert-fox-/crysis2009-01-1422-25-23-04.jpg). Your shadows will look ok when you apply textures over the scene since they'll hide the noise fairly well.

 

 

Once you have jittered shadows, you can try to apply your screen space blur to remove the noise - that should result in a nice soft shadow.

 

Another option is to try VSM or ESM for your shadows - these techniques basically store info that can be blurred and filtered (variance in VSM case, pretty sure it something similar for ESM). Then you just blur it and apply (using the VSM/ESM apply functions of course, it's not a simple depth test anymore). That'll give you noise free, soft shadows. smile.png

 

Maybe google for some more examples/ideas from these techniques, I'm sure one will suit your needs. smile.png


Edited by Styves, 05 March 2013 - 09:18 AM.


#9 Yours3!f   Members   -  Reputation: 1300

Like
0Likes
Like

Posted 05 March 2013 - 03:13 PM

Try using randomly jittered samples, à la Crysis (http://i246.photobucket.com/albums/gg90/desert-fox-/crysis2009-01-1422-25-23-04.jpg). Your shadows will look ok when you apply textures over the scene since they'll hide the noise fairly well.

 

 

Once you have jittered shadows, you can try to apply your screen space blur to remove the noise - that should result in a nice soft shadow.

 

Another option is to try VSM or ESM for your shadows - these techniques basically store info that can be blurred and filtered (variance in VSM case, pretty sure it something similar for ESM). Then you just blur it and apply (using the VSM/ESM apply functions of course, it's not a simple depth test anymore). That'll give you noise free, soft shadows. smile.png

 

Maybe google for some more examples/ideas from these techniques, I'm sure one will suit your needs. smile.png

 

I'm already doing blurring :D but I'll look into the random samples, thanks for the advice!

 

I didn't really like vsm (because of light bleeding), and esm because this way the blurring looks way better, plus it produces correct penumbra too.



#10 Frenetic Pony   Members   -  Reputation: 1277

Like
0Likes
Like

Posted 05 March 2013 - 06:05 PM

Always wanted to see what applying something like SMAA to a shadow map would look like. Tried it once with FXAA and, well it just kinda blurred it, obviously. But I didn't really try anything more than a simple test.

 

In principle AA'ing your scene and a shadow map should have the same objective. Maybe with some work you can get it to com out alright.

 

As for jittered sampling, I absolutely hated how noisy that looked in Crysis. But maybe with burring away the noise it will work? Hope it does.



#11 MJP   Moderators   -  Reputation: 10941

Like
1Likes
Like

Posted 06 March 2013 - 12:31 PM

Pre-filtering a standard shadow map won't fix visible aliasing, since the step function in the shadow map comparison will always re-introduce aliasing. You really need to filter the results of the comparison, which of course is the basic premise of PCF. VSM on the other hand don't have this step function, since it's specifically formulated to work with pre-filtering.



#12 CC Ricers   Members   -  Reputation: 623

Like
0Likes
Like

Posted 07 March 2013 - 05:30 PM

I also agree with the option of randomly jittering the shadow map lookups and then blending them together. The method I use is Poisson distribution. This is pseudo-random, and most of the time, you do not really need to use a Poisson distribution function, but a set of points generated from it. I use these points as a constant array in the shader.

For every pixel just do basic shadow mapping, but offset the shadow texel lookup with each of the sample points. For each sample you blend the shadow color additively in the same way you would do with PCF. This gives an illusion of smoother gradients in most angles, without the pixelated look of PCF so they appear smooth unless you get the camera really close to a surface. Between 10 and 20 samples gives good results. I wouldn't sample many more because you'll be doing a texture lookup every time.


My development blog: Electronic Meteor

#13 Yours3!f   Members   -  Reputation: 1300

Like
0Likes
Like

Posted 08 March 2013 - 10:00 AM

I also agree with the option of randomly jittering the shadow map lookups and then blending them together. The method I use is Poisson distribution. This is pseudo-random, and most of the time, you do not really need to use a Poisson distribution function, but a set of points generated from it. I use these points as a constant array in the shader.

For every pixel just do basic shadow mapping, but offset the shadow texel lookup with each of the sample points. For each sample you blend the shadow color additively in the same way you would do with PCF. This gives an illusion of smoother gradients in most angles, without the pixelated look of PCF so they appear smooth unless you get the camera really close to a surface. Between 10 and 20 samples gives good results. I wouldn't sample many more because you'll be doing a texture lookup every time.

 

well, since I'm doing deferred shadows, it think it would be a constant cost, if I post process the shadow comparison result, and blur later. Or do you mean doing the Poisson on the shadow map itself when doing the comparison to the depth buffer?

But I'll definitely look into this when I have some time.






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