Wednesday, December 19, 2007

Renderer Design

Renderer design is an interesting area. I recommend starting with the lighting equation, splitting it up in a material and light part and then move on from there. You can then think about what data you need to do a huge number of direct lights and shadows (shadows are harder than lights) and how you do all the global illumination part. Especially the integration of global illumination and many lights should get you thinking for a while.
Here is an example:
1. render shadow data from the cascaded shadow maps into a shadow collector that collects indoor, outdoor, cloud shadow data
2. render at the same time world-space normals in the other three channels of the render target
3. render all lights into a light buffer (only the light source properties not the material properties)
4. render all colors and the material properties into a render target while applying all the lights from the light buffer (here you stitch together the Blinn-Phong lighting model or whatever you use)
5. do global illumination with the normal map
6. do PostFX


Unknown said...

I'm confused about what you mean by
"shadow collector" and a "light buffer" here.

Could you eloborate?

Wolfgang Engel said...

The shadow collector is a screen-space texture that holds all the shadow data from all shadow sources. It is usually in screen size or MSAA'ed screen size, which means 1280x720 or 1600x1200.
Light buffer keeps light data only. That means only the light properties of the lighting equation. This light buffer is later used to re-construct the lighting equation.

Unknown said...

Could you elaborate any further ?
First, how do you handle alpha-blend objects (ignore and sample opaque shadow ? or shadow map separately).

Also, why keep them separate if you are lighting deferred ? If you keep them separate, how does the shadow value match to the appropriate lighting value (ie how do you match up a shadow value for light N to the lighting value for for light N). Or are you just approximating ?