Shadow not visible through transmissive object

Hello,

How do I get the shadow on a plane with ShadowMaterial to be visible through an object whose MeshPhysicalMaterial has the value transmission=1?

Here I created a sandbox showing the problem: busy-rumple-6c7ylg - CodeSandbox

You can see the shadow if you’re not looking through the glass.

Thanks.

Is it even possible or do I have to use a different material than ShadowMaterial? I noticed that it works with MeshStandardmaterial for the ground but this leads to a different color of the ground due to the light.

ShadowMaterial does not work since it is a transparent material. The transmission pass only works with opaque and transmissive objects so meshes with ShadowMaterial are discarded.

1 Like

Thanks for your reply!

What kind of material would fit better for this case?

cant you just manually set shadowMaterial.transparent to false

Thanks. This indeed made the shadow visible through the glass: busy-rumple-6c7ylg - CodeSandbox

But now the plane is white. Is it possible to change the color of it to the same color as the scene background. That would be enough for me.

That’s pretty straightforward:

edit: oh wait, you did mean the plane, not the shadow :sweat_smile: then, try this:

p.s. given your current bg color, the value needs to be like this:

2 Likes

You can disable transparency and forcibly set the options automatically set for transparent objects which enables the shadow to render with blending in the opaque objects pass. As you can imagine it’s a bit more complicated to understand and maintain, though.

      <mesh position={[0, -0.5, 0]} rotation={[-Math.PI / 2, 0, 0]} receiveShadow>
        <planeGeometry args={[20, 20]} />
        <shadowMaterial
          transparent={false}
          depthWrite={false}
          blending={THREE.CustomBlending}
          blendSrc={THREE.SrcAlphaFactor}
          blendDst={THREE.OneMinusSrcAlphaFactor}
          blendSrcAlpha={THREE.OneFactor}
          blendDstAlpha={THREE.OneMinusSrcAlphaFactor}
          opacity={0.2}
        />
      </mesh>

7 Likes

Thanks to both of you!

That works perfectly!

btw, you can also use meshtransmission material, it “sees” shadows and other transparent or transmissive objects.