Stippled edges on shadowmaps?

I have seen a screenshots of Alan Wake where shadowmap edges use a stipple as a sort of cheap blur. I do not understand how to implement this effect, specifically how to tell when stippling should be used, and how to apply it to only part of a shadowmap. Can someone explain?

Although, i would first have to see the screen shots but i suspect that that strippple effect is an artifact that is left over from the shadowing shader.
Such strippling usually happens when the shadowed surface is at an high angle to the light and the depth shadow map has a low resolution.

No, I know someone who implemented this in shadowmaps by design.

It’s a variant of PCF, but it uses a rotating random sample pattern instead of a fixed one to get a good pseudo random spread so that you don’t get banding artifacts, it’s especially good if you only have few samples to play with.
If you have a lot of samples a fixed pattern works equally well.

I do not understand what that means.

I usually only use a single shadowmap lookup, but I can do a higher-quality blur using 4 lookups around the target texcoord.

Are there any cheaper ways I can do some kind of edge softening?

And that is essentially what PCF is, instead of one sample you use more samples with slightly “adjusted” texcoords.
Problem with it is if you have a wide blurry shadow and few samples it will look strange indeed, especially if the sample coords are in a straight and rigid pattern, like a square or a circle.
The rotating pattern (as in an array of patterns which rotates around for each pixel) is there so that no adjoining pixel will ever have the same pattern and thus in effect increasing the perceived sample count.

I would advice you to use more than 4 samples per pixel though.

I’ve found that a 3x3 PCF filter works wonders for soft shadows… pretty darn close to what a variance shadow map will get you, in terms of both appearance and speed.

Good old PCF doesn’t suffer from light bleeding artifacts like the variance maps do, but they don’t scale as nicely as VSM, as you move up in filter size. Depends on how soft you want your pillows.

I tried a 3x3 square and was surprised that the framerate only dropped from 70 to 60. That is acceptable.

Now I take it with the random rotation scheme, you choose a random angle and rotate the square by it, somehow creating an illusion of higher samples or higher-res shadowmaps.

rotated grids or any nonuniform sampling pattern can definitely help hide undersampling artifacts.

Check out some of the Nvidia/ATi demos. Most of them use Poisson disk patterns to mix things up a bit.

I found rotated grids to be completely necessay on NVidia cards. Even using 5 samples look fantastic.

On ATI cards there doesn’t appear to be any linear filtering, and banding appears when multiple samples are used. I think I will have to implement a randomly rotated grid on ATI hardware.

I am having a stupid moment, and it is early in the morning. I am trying to do a rotated grid. It looks like it’s creating lines. Here’s the code:

		float seed = (smcoord.x+smcoord.y)*56270.6;
		float ca=cos(seed);
		float sa=sin(seed);
		shadowcolor = shadow2D(shadowmap,smcoord);
		shadowcolor = shadow2D(shadowmap,smcoord);
		shadowcolor += shadow2D(shadowmap,vec3(smcoord.x+ps*ca,smcoord.y+ps*sa,smcoord.z));
		shadowcolor += shadow2D(shadowmap,vec3(smcoord.x-ps*ca,smcoord.y-ps*sa,smcoord.z));
		shadowcolor += shadow2D(shadowmap,vec3(smcoord.x+ps*ca,smcoord.y+ps*sa,smcoord.z));
		shadowcolor += shadow2D(shadowmap,vec3(smcoord.x-ps*ca,smcoord.y-ps*sa,smcoord.z));
		shadowcolor /= 5.0;

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