Thursday 16 October 2008

Covert alpha operations

The screenshot on the left shows my shadow mapping engine rendering two translucent textured surfaces. The first one occludes the spotlight and casts a shadow on the second one which, in turn, casts on the floor and the wall.

Through the eye of the needle

The thumbnail looks fine, but a closer look (click it!) reveils many subtle aliasing problems. Fact is that the "alpha to coverage" is just a workaround to achieve a nice effect (transparency) without adding too much complexity (sorting/splicing/etc). Its trick consists in converting the alpha informations into coverage micropatterns. When the surface is analyzed badly - eg.: shadow map generation from big distance - "non-covert" subfragments reveal themselves. This issue can be partially solved by linear filtering the shadow map, but could also create an awful moiré effect.


Images from the other side

Finally, there remains the open issue of correctly projecting the colors when lights runs through translucent surfaces. The solution I'm trying to develop is the following:
  • render the scene without translucent objects
  • take the depth map of this partial scene (this will block projection beyond dull surfaces)
  • do render anything stays above (using the depth map for depth comparison)
  • take the color map of this scene and blend it over the shadow map
Thoretically it's a working algorythm, but there are surely plenty of complex cases that I'm ignoring.