Finally got cube map depth shadows working...

Boke

New member
It wasn't so hard after all... I am begining to think that shadow volumes may be a better solution though. I don't mind the aliasing to much, but at long light/object distances the shadows tend to jump around a great deal. I'm going to add some percentage closer filtering next... maybe that will help.

The funny looking black cube represents the light. The scene is rendered into the 6 faces of a 512 cube map. The values stored in the cube map rg channels ( using a lookup texture.. Thanks ATI guys!! ) are the cartesian distance from each rendered fragment to the light. Then the cube map is set as a texture for the final render and projected into the scene. The distance ( +ZBias ) is calculated again and compared to the 'projected' distance values.

Using the z distance, you seem to need much less ZBias than you do with z depth. It also seems to be less prone to errors... Heres a pic... ( Resized from 1024x768 ).
CubeMapShadows.JPG
 
Very nice!

As for the jumping around, have you heard of perspective shadow maps? They do some neat transforms to keep the shadow map texel size somewhat uniform across the screen. I saw it at Siggraph, and its quite effective.

I'm going to be doing some pixel shader enhanced shadow maps soon that gives a variable shadow softness based on distance from the shadow caster, i.e. umbra / penumbra stuff. I'll post a demo when I get around to it. You're work is inspiring me to get going!
 
Thanks for the comments!!

Mintmaster:
"As for the jumping around, have you heard of perspective shadow maps? They do some neat transforms to keep the shadow map texel size somewhat uniform across the screen. I saw it at Siggraph, and its quite effective."

Yes I read that a couple of days ago... very interesting.

"I'm going to be doing some pixel shader enhanced shadow maps soon that gives a variable shadow softness based on distance from the shadow caster, i.e. umbra / penumbra stuff."

I'm plan to do the same thing... I'm wondering about the best way to do it though. Should the softness be based on the distance from the caster to the shadow, or the light to the shadow?
I'm not really sure what one would look more natural. My first thought was to use the distance from the shadow caster... But am now leaning toward using the light to shadow distance instead. As the light moves away from the caster wouldn't more of the 'ambient' light reflected from the walls and other objects tend to reduce the shadowing effect as a whole?
By using the caster to shadow distance, the shadow would always be about the same intensity near the caster no matter how far the light was from the object... causing the aliasing problems to be more pronounced.
Hope that made sense :)

"I'll post a demo when I get around to it. You're work is inspiring me to get going!"

I would very much like to see it. Its great that this is becoming possible in real time.
I also want to add support for the lights to shine through alpha objects and project a nice colored shadow. I'm not sure if it will work when a solid and alpha share the same shadowing space without an extra pass though.

Edit:
After thinking about it a bit, the alpha objects should not take part in the shadowing operations at all. They only alter the color of the light as it passes through them. With a 32 bit x4 cube map, I should be able to encode the shadowing and alpha light projections in a single cube map. If I can figure out how to pack the rgb values into the remaing blue and alpha channels of the cube map, It should work on the 8500.

Edit:
Here is another screenshot. I'm really begining to like this shadow mapping ( can you tell ). Notice how the shadow projects on, and through, the translucent surface. The next step is to have the color of the translucent surface projected too.

ProjectThrough.JPG
 
Last edited:
Back
Top