Showing posts with label malfunction. Show all posts
Showing posts with label malfunction. Show all posts

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.

Friday, 19 September 2008

Young 3D engines suffer acne

As the engine grows up, I refactor some routine. Cleaner code allows me to use some higher level function, like a 3Ds objects loader. And here appears a well-know issue: z-fighting.

Even on a surface closest to the light source, you will always discover minor differences in the values associated with the R texture coordinate(...). This can result in "surface acne"(...). You can mitigate this problem by applying a depth offset when rendering in the shadow map:

...
glEnable (GL_POLYGON_OFFSET_FILL);
glPolygonOffset (factor, 0.0f);
...

(...)A balance need to be struck when it comes to polygon offset usage.

from OpenGL superbible 4th edition by Richard Wright (Wesley).
That balance is not so easy to achieve; as Nvidia says in its papers, it's really matter of art.

Monday, 8 September 2008

Neverending story


Something weird is going on here..! Shadows are supposed to be dark! Oo"

..at least they appear now!

Monday, 1 September 2008

Work in progress


The answer to the previous question was: "it does work". I don't know how the framework I'm working on exactly works, but it does strange things with depth buffer.

It seems I'm at a good point. Shadow mapping consists in three steps (two, if the video cards supports the GL_ARB_shadow_ambient extension):
  1. depth buffer acquisition from light's point of view
  2. a "dim light" rendering from camera's point of view
  3. full light rendering w/ shadow map depths comparison
Screenshots prove that everything seems to works correctly.

New question is: why doesn't the shadow map show up..? ^^"
Damn!