Three.js plane doesn't cast shadow

前端 未结 1 862
一生所求
一生所求 2021-01-03 11:21

I\'m stacking a plane and a sphere on top of a bigger plane, as seen in the following image

From WebGL inspector, it seems all three object are drawn in the

相关标签:
1条回答
  • 2021-01-03 11:34

    By default, three.js culls front faces when generating shadow maps.

    renderer.shadowMap.renderReverseSided = true; // default is true
    

    That means only back faces (from the point of view of the light) cast shadows. Culling front faces of your plane leaves nothing left to cast a shadow.

    So one option is to replace your PlaneGeometry with a thin BoxGeometry, which has depth.

    A second option is to set

    renderer.shadowMap.renderSingleSided = false; // default is true
    

    In this case, your plane will cast a shadow, but there may be self-shadowing artifacts since you have both plane.castShadow = true and plane.receiveShadow = true.

    Typically, the first option is the best option.

    three.js r.86

    0 讨论(0)
提交回复
热议问题