Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow shadows to use alphaToCoverage. #30462

Open
lambocorp opened this issue Feb 5, 2025 · 1 comment
Open

Allow shadows to use alphaToCoverage. #30462

lambocorp opened this issue Feb 5, 2025 · 1 comment

Comments

@lambocorp
Copy link

lambocorp commented Feb 5, 2025

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

@gkjohnson
Copy link
Collaborator

Tried using MeshDepthMaterial, but have not been able to achieve any good result with map + alphaTest or alphaMap

It looks like WebGLShadowMap automatically overrides a bunch of material settings, including alphaTest and map, even when a customMaterial is provided, which doesn't seem right if the goal is to let the user control how shadows are cast in a custom way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants