[DX9} Cubic Shadow Mapping

Started by
17 comments, last by DJTN 13 years ago
My shadow maps look like they should but my distance in the light/material shader is always larger than my depth test into my shadowmap.

Advertisement

When you create the projection matrix, use a higher value in the zFar parameter...


Again Tiago, thanks for your help. I changed my texture cube's format to R32F and I'm getting much better results. I also started manually creating each face for the cube so I could actually see what getting rendered to it and made significant improvements with that as well.

I'm almost there, I have the shadows being drawn in the wrong direction. For example, if I have the box a couple of feet off the floor and the light under it, I can see the box's shadow on the floor. Kind of weird but at least I made improvements today. I'll see if I can figure that out tomorrow morning.

When I'm done I'll post some information here in hopes that no one else has to go through what I did to get simple shadows.

Cheers,
Dj
Still having issues and I cannot figure out why. I hope some one, anyone can point me in the right direction.

If the light is on the ground plane in front of the box it draws the shadow from the light to thebox:

5.jpg



If the light moves to the left of the box or any where around it for that matter, the shadows act like a light source.

6.jpg


Any one have any idea's? Am I creating my shadow maps with the wrong tansformations? I've tried several different scenereos and still no change. The shadow is always on the side of the light source.
Well I got the shadow on the correct side by changing the XLightWorld from my world matrix to the world matrix * the Light's view matrix but now I have another problem. The box is included in the shadow.

7.jpg



Anyone ever have this problem before?




Umm ok, no one here to help... Maybe someone could at least tell me another forum where I might get some help?

Try playing around with this value
[color=#1C2837][size=2][color=#000088]if[color=#666600]([color=#000000]distance [color=#666600]<[color=#000000] smDepth [color=#666600]+[color=#000000] [color=#006666]0.001f[color=#666600])[color=#000000]

Try playing around with this value
[color="#1c2837"][color="#000088"]if[color="#666600"]([color="#000000"]distance [color="#666600"]<[color="#000000"] smDepth [color="#666600"]+[color="#000000"] [color="#006666"]0.001f[color="#666600"])[color="#000000"]



If I increase the value there is a large round shadow on the floor whcih eventually encapsulates the box as I move the light closer to the box. if I decrease the value, even subtract it, it skrinks the shadow that the box is in and also the one the box is projecting on the floor mesh.

I was under the impression that cubic shadow mapping allowed an object to be the shadow caster and receiver in one render call, through sampling the depth texture. Am I wrong in this assumption? Do I have to render the shadow maps for every object I render normally, omitting that object so it's not in it's own shadow?

I create my shadow maps (cubic) by rendering everything in the scene through my shadow map shader to a surface (texture). Then I pass that texture to the shaders that I use to render my scene normally. Currently, if the object that I'm rendering "normally" is also in the shadow map render, then it's in its own shadow. Is my issue a draw order issue or does shadow mapping allow for casting AND receiving shadows?
AnyOne?

350 views and no one has anything to add? Are these types of shadows this difficult to work with. Alternatives?
I've figured this out on my own. For those of you struggeling with cubic shadow mapping, TiagoCosta's PS code does work but it's the basic building block. You'll have to massage the code to work with your existing engine/app. To keep my box from being completely encapsulated in a shadow, I added ObjectID's in the green channel of the texture and then checked the ID's when rendering the box normally. This gives me the flexability to mark an object as caster and/or receiver and also allows for objects to shadow each other.

I'm still having issues with jagged edges and trying to soften the shadows without increasing memory usage but it's a fine line you have to ballance.

I chose Shadow Mapping because of it's simplicity, low-CPU overhead and it's ability to handle trasnparency like tree's and billboards - something very difficult with shadow volumes. On the down side, shadow mapping is very hardware dependant - R32 texture format and cube texture for point lights - (that's 6 textures). The larger your textures, the better the shadow accuracy but at a cost.

Thanks to TiagoCosta for his help. I'll continue to watch this post in the event I could help someone else.


Regards,
Dj

This topic is closed to new replies.

Advertisement