Sign in to follow this  
  • entries
    3
  • comments
    3
  • views
    4448

Shadows and such (with pictures :)

Sign in to follow this  
Stuart Yarham

273 views

Hello

After having a GDNet account for a while, I figured it was about time I started using my Journal. I think this might be quite a big first entry too :).

Recently I've been lookng into different shadow mapping techniques, and trying to find out new ways to hide/remove aliasing and shadow acne. Variance Shadow Maps (VSMs) seem like a good candidate, although i've had trouble playing with them at home due to my lacklustre hardware (a laptop with a GeForce FX 5650 Go). Anyway, one of the cool things about VSMs is the fact you can blur the shadow map directly (or let the hardware filter it for you). This got me thinking - what other ways could you use a blurred shadow map? Due to the shadow map test being binary (in/out of shadow), the information about the shadow boundaries is lost when you blur the shadow map. But what if we don't make the shadow test binary, and instead use a kind of fuzzy test?

So, instead of:

float lightAmount = 1.0f;
if((lightSpaceDepth - shadowMapDepth) < 0)
lightAmount = 0.0f;


We do something like this:

float lightAmount = 1.0 - ((lightSpaceDepth - shadowMapDepth) / fuzzyDist);
lightAmount = clamp(lit, 0, 1);

where fuzzyDist is the range where the test result ranges from 0 to 1 e.g. it will give us less shadow where depths are close together. Because our shadow map values now look like this (since they are blurred):

_______
/ \
/ \
_____/ \______

as apposed to this:

_______
| |
| |
_______| |_________


it means we should get a nice soft shadow boundary.

I gave it a go - I made a regular 512x512 shadow map, down sampled it to 256x256 and then ran a 13x13 gaussian blur kernal over it. This is the result:

(Featuring a T-rex by cyberchinchilla from Turbo Squid)
Featuring a T-rex by cyberchinchilla from Turbo Squid

I was quite pleased with the result - there's no aliasing even though the shadow map is only 256x256 and I only have to take a single sample in the lighting shader meaning it runs quickly. What's even better, by increasing the value of fuzzyDist, I was able to increase the blurryness of the shadow at no extra cost.

However, my happyness was pretty short lived when I tried it with other bits of geometry:

Featuring the default DirectX knot

As you can see, using a fuzzy test to determine the amount of shadow, we loose a lot of important information about the scene - the knot is actually resting on the floor, yet the shadow at the point of contact is very weak.

Even worse that that, geometry that isn't primarily smooth in nature looses too much info in the blurring process giving you results like this (please excuse the poor modelling :))




As you can see, the building in the top right is showing lots of false self shadowing. TBH, these are all things that I expected - I didn't really foresee much use in blurring the shadow map, but the results are also more pleasant (and faster) than I assumed.

To try and combat these issues, I'm going to use the original depth map in conjunction with the blurred one, but so far it looks like i'll have to take multiple samples from it to have any useful info to combat the problem.

Anyway, I'll get back shortly if I make any progress.

Cheers,
stoo
Sign in to follow this  


3 Comments


Recommended Comments

Cool stuff. To the casual observer the problems you highlight in the second and thrid pics are actually a lot less problematic than hard edged shadows!

Share this comment


Link to comment
Cheers guys [smile].

I think I may have a fix for the false-shadowing. If that works out with my test data, then I might try and add the technique into a larger environment to see how it looks. I'd like to see it work in conjuntion with CSM/PSSMs etc.

I tried my demo on my NV 7800 GTX at work and got ~740 fps compared to the ~27 fps I'm getting on my NV 5650 GO. It really is time to upgrade my home PC... the NV 8800 GTX is looking awful nice [totally]. (Of course, that means a new machine as well, but oh well [smile])

stoo

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now