What causes this shadow gradient effect?

See how these shadows taper off with an obvious “wave” like effect? Does anyone know what causes that and how I can be rid of it?



(You may have to open the link separate to get a bigger image

http://s4.postimage.org/vfs93zr58/shadows.jpg

http://s4.postimage.org/ksyj9n80a/shadows2.jpg)











For the second image this is what I’m doing currently:



[java]

pssmRenderer = new PssmShadowRenderer(assetManager, 4096, 4);

pssmRenderer.setDirection(new Vector3f(-0.9f, -0.45f, 0.9f).normalizeLocal());

pssmRenderer.setEdgesThickness(200);

pssmRenderer.setLambda(0.55f);

pssmRenderer.setShadowIntensity(0.45f);

pssmRenderer.setCompareMode(CompareMode.Software);

pssmRenderer.setFilterMode(FilterMode.PCF8);

viewPort.addProcessor(pssmRenderer);

[/java]



Also, I see that there are other shadow references in the API, but the examples seem bugged when they’re run. Are these left over from jME2? What other methods (other than PssmShadowRenderer) are there for generating shadows (a single mesh casting shadows onto itself), and do we have any examples?

These artifacts are due to pcf filtering.

There is no really built in way to reduce efficiently these artifacts. The best i know would be to implement jittered filtering (some randomness applied to filtering samples of the shadow edges). This does not remove the artifact but mak eit a lot less noticeable to human eye.



But maybe you can first try to reduce the edge thickness. 200 is a bit too much

After some toying with a few things, it seems gone from most shadows, but in some rarer cases it’s still pretty bad. Seems to be worse when the light direction is most perpendicular to the surface it’s hitting (but still casting a shadow), but not always.



I think I’m going to need to figure out how to do some filtering or some such like you suggest…



Unfortunately what seems to have the most effect also kills FPS the most (and kills the entire app if it’s set too high - so I’m concerned about lower end graphics cards) - the size of the shadowmap. It’s pretty high now:



[java]

pssmRenderer = new PssmShadowRenderer(assetManager, 8192, 1);

pssmRenderer.setDirection(new Vector3f(-0.8f, -0.4f, 0.7f).normalizeLocal());

pssmRenderer.setEdgesThickness(10);

pssmRenderer.setLambda(0.85f);

pssmRenderer.setShadowIntensity(0.25f);

pssmRenderer.setCompareMode(CompareMode.Software);

pssmRenderer.setFilterMode(FilterMode.PCF4);

viewPort.addProcessor(pssmRenderer);

[/java]

http://s2.postimage.org/gtz5lk3ob/shadows3.jpg



Yeah it’s weird, I can get things looking okay on any other texture, but for some reason this snowy/white area they ALWAYS look like crap, and even a relatively flat ground area casts shadows. I may have to drop this method entirely and go with something else, hmm. And edge thickness is hardcoded to be 1-10 only. :slight_smile: