-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
In the following scene, a simple mesh is constructed from a basic plane mesh:
commands
.spawn_bundle(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Plane { size: 1.0 })),
material: materials.add(StandardMaterial {
base_color_texture: Some(chara_texture.clone()),
double_sided: false,
alpha_mode: AlphaMode::Mask(0.5),
..Default::default()
}),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..Default::default()
});
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
has AlphaMode::Mask
, it should automatically cast shadows using the same mask for transparency. If this is infeasible, a built-in ShadowTextureMask{ ... }
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 using AlphaMode::Mask(0.1)
for shadows).