Jump to content
  • Advertisement
Sign in to follow this  
mrbig

Improved Shadowmapping

This topic is 4525 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Shadowmapping is fast and simple, it can cast shadows on everything (including self shadowing), it can be used to create soft shadows (by using multiple point lights) and still remain fast. But it has one big flaw: aliasing. But I came up with a way to solve it while using as low shadowmap resolutions as 64x64. All you need to do with the shadowmap is: 1. Anti-alias it 2. Blur it using gaussian blur with a very small radius 3. Use texture filtering All that can be done using fragment shaders, and since the resolution and the amount of blur is very small, there's a very little number of fragments to process so it should be fast. Here's an example of the results of such filtering. A 32x32 square scaled to 512x512. The square was 32x32 before it was scaled. No aliasing appears. Altough it wasn't supposed to have smooth edges, we can use that to our adventage too when using multiple point lights to create soft shadows! The smooth edges will make the transition between one shadow to another smooth!

Share this post


Link to post
Share on other sites
Advertisement
I'm not a very skilled OpenGL programmer.
And GLSL is driving me nuts, working and not working randomly...
If you think this might work, try to implement it and show me the results. :)
Should work, theoretically... Shadowmaps can be filtered, right?

Share this post


Link to post
Share on other sites
sorry for the bad news but it wont work, as u cant blur depths. u can do PCF comparision which is similar though.

Share this post


Link to post
Share on other sites
Ok, so, what if we render the scene to a texture from the light's point of view and than project that texture on the scene from the light's position?
Should produce the same results as shadowmapping, right?
And it should be even cheaper than shadowmapping...

Share this post


Link to post
Share on other sites
I dont know much about shadow mapping as I have yet to implement it in my engine but I dont think

Quote:


Ok, so, what if we render the scene to a texture from the light's point of view and than project that texture on the scene from the light's position?
Should produce the same results as shadowmapping, right?
And it should be even cheaper than shadowmapping...



Will work as all your geometry will be the shadow color, as you dont determine if its behind the blocker with the depth test! ( You would effectively
project a black texture :) )

I think though in AOM what they might have done is simply project a pre-rendered texture onto the terrain to give the impression of shadow mapping. But you wouldnt get self shadowing this way.

Mark

Share this post


Link to post
Share on other sites
As zedzeek said, this won't work because you can't directly filter depth values. It's good to see that some people can still think for themselves though [smile]. What you can do is store the shadow map in a different way, one which does let you filter it anyway you like. See Variance Shadow Maps for example. I haven't implemented it, but from reading the paper and that thread it seems like it could be a very good solution.

EDIT: And just for more clarity, PCF (Percentage Closer Filtering) is a technique of filtering the depth comparisons. What you basically do is run the depth comparison for several samples in the shadow map and then filter the results of all those comparisons to get some percentage that the current fragment is shadowed. Depending on the number of samples you use it can offer decent results, but the more samples you take the slower it goes.

Share this post


Link to post
Share on other sites
Here's a description of a demo I found at http://pages.pomona.edu/~nrr02004/opengl.html

"This demo demonstrates shadow mapping. Radeons don't support rendering directly to depth textures, so the 512x512 shadow map is rendered to a pbuffer and then copied to a texture. The light is omnidirectional but only one shadow map is used; this can be done since the table is the only shadow caster in the scene. Light space projection, clipping, and 4-sample PCF (percentage-closer filtering) is done by the fragment shader. In a real application of shadow mapping, one would use a cubemap for omnidirectional lights."

I think that solves the problem! :D
Sounds a bit messy, though...

By the way, check this page out: http://dee.cz/fcss/
It has a demo demonstrating soft shadows using shadowmaps. (Not filtered, but it's pretty cool.)

Share this post


Link to post
Share on other sites
Quote:
Original post by mrbig
Ok, so, what if we render the scene to a texture from the light's point of view and than project that texture on the scene from the light's position?
Should produce the same results as shadowmapping, right?
And it should be even cheaper than shadowmapping...

i think u mean, render an object/s from the lights position and projection this black texture onto the scenery behind it.
yes this used to be used quite often (i forget the graphics term its called) the problem with it is it doesnt handle selfshadowing

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!