Yeah, that doesn't quite line-up with how it's explained at iddev.net
Step 1:
Renders all solid (non-translucent) geometry in black. If a stage has an alpha test, then it gets rendered with the alpha test enabled. This is to fill the depth buffer so early z can prevent expensive shader ops later.
Step 2:
Render all light interactions.
For each light {
Render shadows into the stencil buffer;
For each stage in the light material {
For each surface in the light volume {
inter.diffuse = inter.specular = inter.bump = NULL;
For each stage in the surface material {
if stage is Diffuse {
if ( inter.diffuse && inter.bump ) Render( inter );
inter.diffuse = thisStage;
}
if stage is Specular {
if ( inter.specular && inter.bump ) Render( inter );
inter.specular = thisStage;
}
if stage is Bump {
if ( inter.bump ) Render( inter );
inter.diffuse = inter.specular = NULL;
inter.bump = thisStage;
}
}
Render( inter );
}
}
}
Step 3:
Renders any stage with "blend" set to something other than "diffusemap", "specularmap", or "bumpmap". This is where guis and other translucent or alpha blended surfaces get rendered (including particles).
Step 4:
Render any stage that references _currentRender. This would be heat haze, glass distortions, and other crazy post process effects.
To stay safe, I would always put my stages in the following order: bump, diffuse, specular. That way you'll always know how it will get rendered.
If the above is true, then it should be possible to reference the internal depth buffer for SSAO without writing a new one. Too bad I'm not bright enough to
tell either way...
