Blender exporter shadows not working properly

Your link has some problems, when changing the shadow filtering method I get errors in the console and I can’t enable/disable the shadows…

I don’t have those problems with the samples linked from the shadow doc, so I made a local PG with your asset (no problem either).

For reference, here the PG but it won’t work because it is looking for the asset locally on my computer. I can’t link to your live asset because of CORS problems.

To have good shadows, you need to tweak a number of parameters as described in the shadow doc. For shadow acne it is mainly bias (and normal bias), but you need to also tweak some other values to get the most of the shadows.

To demonstrate this, here’s your scene with the default values:


The colored box shows the light volume that will be used for shadow map rendering: the smaller the volume, the better the shadows, the gist is that all the shadow casters should be in the volume. As you can see, it is quite big in the picture (and it still goes far down).

Now let’s remove the plane from the shadow caster list as it can’t cast shadows on the cube:


Far better, no more acne on the plane as it is not a caster anymore, and the light volume is much smaller as it does not have to take into account the plane.

Still, the volume has too much extent:


I have updated the light.shadowMinZ (value = 3.5) and light.shadowMaxZ (value = 8) properties to tightly fit the cube.

Now that we have a good volume, we can tweak the shadow parameters to display good shadows (in the following pictures I have removed the volume gizmo and added an environment texture so that we can better distinguish the shadows from the cube).


In this one, I have simply set depthScale=5 and bias=0.1 in the shadow generator, the filtering method being the one you set in the asset (Blurred exponential).

Depending on the filtering method used, you may need different bias values. For eg, here’s a picture with filtering method = PCF:


As you can see at the left and right corners of the cube, there are some artifacts: the bias value (0.1) is too big and some shadows are lost.

Here’s the same picture but with bias = 0.01:


No more artifacts.

Hope that helps.