• entries
3
3
• views
4545

Shadows and such (with pictures :)

379 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 :).

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)

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:

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

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!

Welcome to journal land!

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

Create an account

Register a new account