Skip to content

Commit 27ee85b

Browse files
committed
Add shadow biais to avoid shadow acne
Don't show in changelog
1 parent bbe2d18 commit 27ee85b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Extensions/3D/DirectionalLight.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ namespace gdjs {
6666
}
6767
this._shadowMapDirty = false;
6868

69+
// Avoid shadow acne due to depth buffer precision. We choose a value
70+
// small enough to avoid "peter panning" but not too small to avoid
71+
// shadow acne on low/medium quality shadow maps.
72+
// If needed, this could become a parameter of the effect.
73+
this._light.shadow.bias =
74+
this._shadowMapSize < 1024
75+
? -0.002
76+
: this._shadowMapSize < 2048
77+
? -0.001
78+
: -0.0008;
79+
6980
this._light.shadow.mapSize.set(
7081
this._shadowMapSize,
7182
this._shadowMapSize

0 commit comments

Comments
 (0)