Shadows painted wrong with bias set up

Hi,

It is seems like a bug (all revisions affected) when shadow is truncated in some cases (example):

  1. There are two materials - first with FrontSide and visible set true, second with BackSide and visible set false:
const sphereMaterial = new THREE.MeshStandardMaterial( { side: THREE.FrontSide, color: 0xff0000 } );
const cloneMaterial = new THREE.MeshStandardMaterial( { side: THREE.BackSide, color: 0x0000ff } );
cloneMaterial.visible=false;

Shadow is painted correctly (!!!) if cloneMaterial visible is true (just comment cloneMaterial.visible=false; and rerun)

  1. Same wrong shadows when both materials are visible and BothSide or FrontSide:
const sphereMaterial = new THREE.MeshStandardMaterial( { color: 0xff0000 } );
const cloneMaterial = new THREE.MeshStandardMaterial( { color: 0x0000ff } );

visibility of second material doesn’t affect on shadow at all.

How to resolve this issue if I need bias and it should be not 0 and ability to hide material to prevent its being painted in mesh that cast shadow ?

If you mean the separation between the shadow on the ground, and the cube itself… I don’t think that’s a bug. It’s a known side effect when using shadow.bias to fix shadow acne. It even has a name… it’s called “peter panning”… where shadows “float” above the surface

c++ - OpenGL shadow peter-panning - Stack Overflow.

If i reduce your .bias to:
light.shadow.bias = -0.0001;

It goes away…

1 Like

Thank you for an explanation!

1 Like