For Ogre experienced people, but also experts in the field: Early Z culling is sometimes quite desirable, and that's what I tried to do in Ogre by using a two pass material. The first one is writing to the Z Buffer, but not to the frame buffer. This is how it looks like:
pass EarlyZ
{
texture_unit TU0
{
//ambient diffuse texture
texture $TU0_TEXTURE
tex_coord_set 0
filtering trilinear
}
//cull_software none
//cull_hardware none
lighting off
colour_write off
shading flat
//scene_blend alpha_blend
alpha_rejection greater_equal 200
depth_bias -5 -5 // ugly hack - without it, objects tend to flicker
}
The biggest problem I get is with alpha objects and shadows. For example, now I can't get tree impostors to cast correct shadows instead of blocks. Although they are rendered correctly, the PSSM isn't working correctly, so the shadows tend to look like stencil shadows. Any ideas on how to fix it? As many people said: is it possible to perform early Z culling and still have transparent objects in the scene? If yes, some hints to do it in Ogre? Here are some screenshots: