Interesting idea for producing shadows for directional, point & spot lights

I’ve been thinking a bit about this lately… and I think I have come up with an approach that is (at least) semi-unique.



Creating shadows as a post process using reflection. I’ll explain the idea behind it and I would really like some input to sum up the concept prior to trying it.



The basic idea is to produce accurate shadows for all objects (all being every object casts and receives shadows) at once using reflection based off the light position, light direction and the -light direction against either a normal map, depth map… or combination of the two.



Off the top of my head, I see one potential drawback (for infinite distance directional lighting)… but it is no more intensive than using the shadow cam… to ensure that shadows from objects outside the rendered scene display… the scene would need to be rendered from behind the camera position. And I’m not convinced this would solve other issues for this particular type of lighting.



I’m not sure if this is a completely feasible idea… so I wanted to run it by people smarter than me. It’s an interesting approach and worth at least exploring conceptually.



This idea may be more feasible for point & spot light shadow casting… as infinity distance directional lights would be a bit more difficult to define in the reflection process.



Thoughts?

I also thought it worth mentioning… this method, if used for at least producing shadows for confined lighting, doesn’t actually require creating a light or adding it to the scene.

I don’t think you’ve provided enough information for us to know how shadows are actually calculated in this approach. You’ve described the goals pretty well but I don’t know how you get from “rendered from behind the camera” to shadows.

Yeah, i don’t really get how it’d work.

What do you mean by using reflection?

Hmmm… I just hooked up the IV drip of caffeine, so bare with me if this doesn’t make 100% sense. Hopefully it will explain the idea a little better.



The way ambient occlusion is performed is to perform reflection in random directions at a set radius based off the normal of the current pixel sample. Wouldn’t it be possible to use the same basic technique to sample either the direction of the light & the inverse of that direction, or the the direction of the light source and the inverse of that direction to produce shadow maps?



This idea (as stated in the OP) would probably not work for infinite distance directional lights (there is way to much data outside the rendered scene needed to use it for this purpose)… but should work rather well for small radius point lights (such as running by a torch, etc, etc) and limited ranged spot lights. Since the technique would not need the actual lights to generate the shadow maps, the user could define light placement/direction as part of the filter setup.



Anyways… the idea may not be possible, but because there be smarter people here than myself, I really wanted to see if anyone else sees something I am missing and can point these things out prior to even attempting the idea.

So you’d cast a ray out from a rendered point and hope to hit a light source? What if you miss?



Why is this better than the current lighting? (Note: you can’t really get proper shadows since there isn’t enough information in the z-buffer and your lights would be limited to only casting shadows for things that are currently in view. Note: this is also why full screen AO will never produce physically accurate results.)



Unless I’ve misunderstood your explanation… but I’m not sure how else to interpret it. Maybe a diagram would help.

@pspeed said:
So you'd cast a ray out from a rendered point and hope to hit a light source? What if you miss?

Why is this better than the current lighting? (Note: you can't really get proper shadows since there isn't enough information in the z-buffer and your lights would be limited to only casting shadows for things that are currently in view. Note: this is also why full screen AO will never produce physically accurate results.)


To the first question... not hope it hits a light source, but determine if another object is in-between it and the light source... and the reverse for self shadowing. Hopefully creating perspective shadowing.

And to the second part... the idea was a way to produce shadow casting effects for smaller light sources (like the use of omni directional lights for torches without the need for omni directional lights. It would not be incredibly accurate due to lack of rendered data... but was an idea for a fast way of producing these lighting effects as a post effect.

Whether or not it is worth pursuing? I don't know... that's why I brought it here :)

The number of trivial cases where this will fail or look really glitchy outweighs the number of cases where it will work, I think. Here are a few trivial examples where shadows would disappear strangely:



http://i.imgur.com/pkgox.png



The second one is the pathological case where shadow casters just aren’t on the screen. The first is where the shadow casters are obscured by other geometry. Either way, shadows would pop in and out of view unpredictably (from the player’s perspective). And the first case gets even weirder when the pillar is only partially obscured since then you’d get a weird shaped shadow on the wall.

3 Likes

That’s the info that made the deciding factor. Thanks a TON for looking over this… saved me a ton of time!

@t0neg0d

The approach you suggest can be used to implement reflections in screenspace. AFAIK Crysis uses this technique on High/Ultra settings.

http://www.youtube.com/watch?v=907vQsHofPM



Here’s a try from someone at gamedev…

http://www.gamedev.net/blog/1323/entry-2254101-real-time-local-reflections/

1 Like