Shadows changing with camera rotation

As you can see in the images below, I noticed that changing the camera angle relative to a shadow makes it more and more blurry as you approach 90 degrees relative to it. I’m quite sure that I followed the “light and shadows” tutorial to the letter and yet it seems that something is missing. I’d be good to know what the setLambda() actually does “reduce the split size” doesnt really tell me anything. Also adding shadow stabilization doesnt have any effect whatsoever.


I lightened the following image to make it easier to see.

The code I’m using:

    FilterPostProcessor fpp=new FilterPostProcessor(assetManager);
	
    final int SHADOWMAP_SIZE=2048;
    DirectionalLightShadowRenderer dlsr = new DirectionalLightShadowRenderer(assetManager, SHADOWMAP_SIZE, 2);
    dlsr.setLight(sun);
    dlsr.setEdgeFilteringMode(EdgeFilteringMode.Bilinear);
    dlsr.setEnabledStabilization(true);
    viewPort.addProcessor(dlsr);

    DirectionalLightShadowFilter dlsf = new DirectionalLightShadowFilter(assetManager, SHADOWMAP_SIZE, 2);
    dlsf.setLight(sun);
    dlsf.setEnabled(true);
    dlsf.setEnabledStabilization(true);
    fpp.addFilter(dlsf);
		
    viewPort.addProcessor(fpp);

This seems like a thing that would have an obvious and easy fix, but i cant seem to find anything that would help.

Did you tried to use more shadowmaps ? You are using just 2, try it with 4.
About the lambda, I never used, but I guess it has to do with the pixelazetion of the shadow, if not, then this javadoc really need more info.

1 Like

I tried using 1, 3 and 4 just now and its pretty much the same. But I did go check the javadoc (only checked the tutorial page before since the javadoc is usually a barren wasteland) but I surprisingly found this under setLambda:

Adjust the repartition of the different shadow maps in the shadow extend usualy goes from 0.0 to 1.0 a low value give a more linear repartition resulting in a constant quality in the shadow over the extends, but near shadows could look very jagged a high value give a more logarithmic repartition resulting in a high quality for near shadows, but the quality quickly decrease over the extend. the default value is set to 0.65f (theoric optimal value).

So I tried messing around with the lambda a bit and setting it to 1.0f appears to solve the problem. Weird.
Thanks :smiley: