Concerning Shadow Maps
I'd like to put together a small first person shooter where one character on a team can "jump" in-between shadows on a small, quake style map. Essentially what I would like to implement is that when a character walks into a shadow of sufficent depth and size a small min-map pops up, and he can basically teleport himself across the map if he can find a shadow of comparable size elsewhere (it would be great for discouraging camping). Ideally the shadows would be generated in real time. I'm sure it's possible on some level, but is such a thing practical using XNA?I think I could do it using baked-in "shadow-maps" but what about real-time?
Research stencil shadows.
They basically extrude edges to infinity away from a light source and those edges can be considered planes. If you divide them into convex sections, you can treat them as k-DOP’s, and from there it is fairly simple to detect if the player is inside one.
These can be pre-computed unless the light source is moving.
L. Spiro
They basically extrude edges to infinity away from a light source and those edges can be considered planes. If you divide them into convex sections, you can treat them as k-DOP’s, and from there it is fairly simple to detect if the player is inside one.
These can be pre-computed unless the light source is moving.
L. Spiro
What do you mean by "sufficient depth and size"?
If you're using shadow maps, an alternative to the above analytical method is to
If you're using shadow maps, an alternative to the above analytical method is to
- render the player's depth (PD) from the light's point of view (clear this depthmap to 0 beforehand)
- do a compare with your existing shadow map (SM) in some pixel shader (if PD == 0 ignore, if PD == SM (+/- epsilon) then it's not in shadow, if PD > SM it's in shadow)
- reduce to 1x1 (how you reduce depends on what information you want)
- read back
What do you mean by "sufficient depth and size"?
If you're using shadow maps, an alternative to the above analytical method is to
- render the player's depth (PD) from the light's point of view (clear this depthmap to 0 beforehand)
- do a compare with your existing shadow map (SM) in some pixel shader (if PD == 0 ignore, if PD == SM (+/- epsilon) then it's not in shadow, if PD > SM it's in shadow)
- reduce to 1x1 (how you reduce depends on what information you want)
- read back
The character's model would have to fit inside of the shadow.
[quote name='jameszhao00' timestamp='1318905640' post='4873730']
What do you mean by "sufficient depth and size"?
If you're using shadow maps, an alternative to the above analytical method is to
- render the player's depth (PD) from the light's point of view (clear this depthmap to 0 beforehand)
- do a compare with your existing shadow map (SM) in some pixel shader (if PD == 0 ignore, if PD == SM (+/- epsilon) then it's not in shadow, if PD > SM it's in shadow)
- reduce to 1x1 (how you reduce depends on what information you want)
- read back
The character's model would have to fit inside of the shadow.
[/quote]
[s]I assume you mean when the light source is inside the player (seems very unlikely, but...)
Assuming your player is watertight, turn on backfaces when rendering the player[/s].
Oops totally misread what you posted
In your comparison, add an additional rule: if PD < SM output some unique failure value.
In your reduction, take into account this unique failure value.
What about hardware occlusion queries? You render the scene from POV of the light/shadowcaster using occlusion queries and if the player is occluded (to a certain value?), he is inside the shadow.
shadow
shadow
What do you mean by "sufficient depth and size"?I suppose it might be sufficient to check if the player's bounding box fits the convex assembly. If all the points of the box are in some "shadow" hull (assuming no intersection) then the player is shadowed.
Note however this does not quite work as you probably expect: in real life, it just does not work that way. Being in shadow does not make you invisible, it only makes the model dark, and this will effectively hide it only when the background is dark as well.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement