Negative offset to Shadow2DProj result in moiré

Hi!

Im trying to do PCF-Shadow mapping but I’ve hit a problem that I can’t make sense of. I use shadow2DProj which works fine (with and without Nvidia hardware PCF).

float shadowing = shadow2DProj(shadowMap, shadowCoords).x;

But when I try to add a negative offset to the shadowCoords it result in a moiré-like pattern. This do not happen when I add a positive offset. Btw, with negative offset I mean that the x or y component is negative.
Image of the scene with moiré

Increasing the Polygon offset when rendering the shadow map removes the moiré. What Im wondering is why it only occurs with negative offsets and not positive? Any clues?

Thanks!

/Andreas

You get moire pattern when some pixels pass the compare and some don’t. So, some pixels are in shadow and some are not. You probably can deal with it by applying a greater offset with glPolygonOffset() so that parts that should be lit stay lit.

Thanks for the quick response. As I wrote in the my original post increasing the polygon offset does remove the moiré. So the problem is already solved, and it is more out of curiosity that I wonder why:

float shadowing = shadow2DProj(shadowMap, shadowCoords-offset).x;
resulted in a moiré but not
float shadowing = shadow2DProj(shadowMap, shadowCoords+offset).x;

I’ve not been able to recreate this again but i have an idea why this happened. The light had a direction that made -offset push the sample position up the slope of the polygon. While offset pushed the sample position down the slope.

/Andreas

FWIW, variance shadow maps eliminate that sort of artifact altogether in exchange for a little light bleeding under the right (wrong) conditions. They work exceptionally well if there’s little variance in depth between the caster and receiver (not enough o’s in smoooooth).

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.