-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Transparent base_color_texture with AlphaMode::Mask should make shadow casters transparent #4372
Comments
I haven’t looked into any they about how this should be done but I suspect it’s as simple as having to implement opaque and alpha mask shadow phases where the alpha mask phase has a fragment shader that discards similar to the pbr shader. I haven’t yet had to implement a fragment shader that doesn’t return anything. All this has to do is check the alpha for the fragment and discard or not. I don’t know if that is a valid fragment shader. |
+1 I would love to have this |
Second. Objects like foliage make heavy use of this and is a must-have. |
# Objective - Fixes bevyengine#4372. ## Solution - Use the prepass shaders for the shadow passes. - Move `DEPTH_CLAMP_ORTHO` from `ShadowPipelineKey` to `MeshPipelineKey` and the associated clamp operation from `depth.wgsl` to `prepass.wgsl`. - Remove `depth.wgsl` . - Replace `ShadowPipeline` with `ShadowSamplers`. Instead of running the custom `ShadowPipeline` we run the `PrepassPipeline` with the `DEPTH_PREPASS` flag and additionally the `DEPTH_CLAMP_ORTHO` flag for directional lights as well as the `ALPHA_MASK` flag for materials that use `AlphaMode::Mask(_)`.
In the following scene, a simple mesh is constructed from a basic plane mesh:
The mesh itself is transparent ("cut out" where the alpha of the texture is more than 0.5) but the entire plane casts a shadow. This means that it casts a shadow in a different shape than the object itself.
What problem does this solve or what need does it fill?
Meshes textures with transparency using
AlphaMode::Mask
can cast shadows that match their shape in space.What solution would you like?
When a
StandardMaterial
hasAlphaMode::Mask
, it should automatically cast shadows using the same mask for transparency. If this is infeasible, a built-inShadowTextureMask{ ... }
component could be an alternative solution.What alternative(s) have you considered?
In some cases, the shape of the object could be constructed out of geometry instead of using textures, or a custom alternative shadow pass could be built. This would be a lot of work to match the probably "expected" behavior.
Additional context
It's not entirely clear how shadows should behave for transparency with
AlphaMode::Blend
, so that's out-of-scope for this issue. Using a separate component (even optionally) could make this clearer, by allowing different strategies for the shadow and the mesh in the standard pipeline (e.g. blend transparency in the main pipeline, while usingAlphaMode::Mask(0.1)
for shadows).The text was updated successfully, but these errors were encountered: