PDA

View Full Version : How to render shadows in a environment



P51D_mustang
02-08-2014, 08:58 AM
Hi

I've searched a lot of tutorials and examples in the internet, but I'm a little bit confused:
How are shadows rendered in realtime?
I've seen some examples with shadow mapping and the stencil buffer. But I can't belive that opengl can handle light sources (color difference from back and frontside of lighted objects) but a simple shadow can't be rendered so simple?
And it isn't realy nice to render the hole scene from different views (light positions) to define, where the lighted faces are and where the shadow is.

How is this done usually? (And don't tell me, that this is done the same way as 1977 with the first shadow maps..) When I compare with newer game (eg ARMA 3) there are a lot of shadows and it is one of the detailled 3d games I've evere seen, so it can't be that the hole visible world is rendered ~10 * 60hz (that is extremly inefficient).

Hope, you can show me the right way.
Best regards.

mhagain
02-08-2014, 09:31 AM
The whole visible world isn't rendered, but otherwise yes - the approach is still essentially unchanged.

First of all, not every light is potentially a shadow-casting light. Some lights are used for just "fill".

Secondly, and with point lights, only objects within the range of the point light need to be rendered. If your world is 5000x5000 but you've got a light with a range of 300, then obviously anything outside of that 300 range is unlit, and won't recieve a shadow from that light.

Thirdly, there are a whole bunch of tricks, optimizations and suchlike that can be used for shadows. At the simplest level, a shadowing pass doesn't need textures, doesn't need lighting, doesn't need complex materials, etc. So it's not equivalent to a lit pass, and can often be drawn substantially faster.

Unfortunately there's no such thing as a "simple" shadow, since shadows rely on knowledge of how objects are positioned and oriented with respect to each other in 3D space and from the perspective of a light, which is information that you just don't otherwise have access to. You have to do it the hard way.