Sign in to follow this  
timothyjlaird

Concerning Shadow Maps

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
What do you mean by "sufficient depth and size"?


If you're using shadow maps, an alternative to the above analytical method is to
[list][*]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[/list]

Share this post


Link to post
Share on other sites
[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
[list][*]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[/list]
[/quote]
The character's model would have to fit inside of the shadow.

Share this post


Link to post
Share on other sites
[quote name='timothyjlaird' timestamp='1318906337' post='4873736']
[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
[list][*]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[/list]
[/quote]
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. Edited by jameszhao00

Share this post


Link to post
Share on other sites
[quote name='jameszhao00' timestamp='1318905640' post='4873730']What do you mean by "sufficient depth and size"?[/quote]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.

Share this post


Link to post
Share on other sites

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

Sign in to follow this