Skip to content

Allow shadows to use alphaToCoverage. #30462

@lambocorp

Description

@lambocorp

Description

For a texture with transparency, alphaTest can be used, but if using alphaToCoverage instead, shadows lack alpha. This is problematic for cases like grass billboards where the docs recommend to use alphaToCoverage, but don't explain how / what needs to be configured to get alpha on the shadow.

Here's an example:
https://codesandbox.io/p/sandbox/exciting-water-hz8k92

Solution

When writing to the shadow map, don't just consider alphaTest, but also alphaToCoverage.

Alternatives

Tried using MeshDepthMaterial, but have not been able to achieve any good result with map + alphaTest or alphaMap. However, using alphaHash is showing transparency in the shadow now so that is helpful.

mesh.customDepthMaterial = MeshDepthMaterial({ alphaHash: true })
mesh.customDepthMaterial.depthPacking = RGBADepthPacking

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions