views:

313

answers:

1

I currently have a deffered rendering system setup and can render point lights and directional lights. My question is what are my options for different forms of shadowing which can make shadows based on point lights and directional lights which can maybe make use of a deffered shading setup?

+4  A: 

There's not really anything special about deferred rendering that requires unique shadowing techniques. Most of the standard approaches to producing shadows work just fine with deferred rendering schemes.

Shadow mapping is the most common shadowing algorithm in use today in real time applications like games. Stencil shadows were popular a few years ago but have fallen out of favour a bit due to various limitations. Shadow mapping works fine with deferred shading. The basic algorithm for shadow mapping is reasonably straightforward:

  1. Render depth to a render target texture from the point of view of the light (you need to render 6 faces of a cube map for a point light).
  2. When you perform the lighting pass for the light, for each pixel transform the world space position to the light's view space and compare the depth to the depth stored in the shadow map. If it is greater than the shadow map depth then the point is in shadow, otherwise light it normally.

As usual with rendering, the devil is in the details. In order to get good quality shadows you need to set up your shadow map projection carefully to make best use of the pixels available in the shadow map (search for perspective shadow maps, cascaded shadow maps). Due to precision issues you will get various artifacts with self shadowing surfaces ('shadow acne' is the most common one) and there are various strategies to reduce the incidence of these artifacts (depth bias, projection matrix tweaks). In order to reduce the blocky, pixelated look of shadow maps with insufficient resolution you will probably want to perform some shadow map filtering. Percentage Closer Filtering is the standard approach and there are various ways to go about performing PCF.

You also face the standard quality/performance tradeoff with shadows and dynamic shadowing tends to be one of the most expensive aspects of scene rendering. There are numerous tricks and techniques to attempt to maximize the performance of shadow mapping.

Recently there have been a number of variations on the basic shadow mapping algorithm that attempt to give better looking results for a given shadow map resolution by approaching the filtering problem differently. Variance Shadow Maps and Exponential Shadow Maps are two recent techniques that have some nice benefits but some unique problems of their own.

Nvidia's developer site is a good resource for graphics programming in general and has lots of articles on shadowing. Take a look at the HTML versions of the GPU Gems books available on the site as well, they have various articles on shadowing, including the definitive article on Variance Shadow Maps in GPU Gems 3.

mattnewport