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

AlphaMode::Mask keeps shadow on invisible objects #4969

Closed
MiniaczQ opened this issue Jun 8, 2022 · 4 comments
Closed

AlphaMode::Mask keeps shadow on invisible objects #4969

MiniaczQ opened this issue Jun 8, 2022 · 4 comments
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior

Comments

@MiniaczQ
Copy link
Contributor

MiniaczQ commented Jun 8, 2022

Problem

While AlphaMode::Opaque renders shadow as intended, AlphaMode::Blend renders shadow in full opacity as intended,
AlphaMode::Blend(f32) still renders shadow on all objects, despite them only being fully opaque or fully transparent.

Example

This is clearly visible in the transparency_3d example. (One of the spheres is masked away, yet still has a shadow)

image

@MiniaczQ MiniaczQ added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jun 8, 2022
@superdump
Copy link
Contributor

This was covered in another issue but I don’t remember which it was at the moment.

@superdump superdump added A-Rendering Drawing game state to the screen and removed S-Needs-Triage This issue needs to be labelled labels Jun 9, 2022
@MiniaczQ
Copy link
Contributor Author

MiniaczQ commented Jun 9, 2022

I've checked 2 other issues which had to do with Mask and shadow casting, but I didn't see it pointed out, at least directly.
Those are:
#4576 - platform issue
#4372 - similar, but about the shape of the shadow instead

I guess the main difference is, if the whole object is masked away, there is no need to render it (or the shadow) whatsoever.
Technically, fixing #4372 would fix this, but this would be more optimal?

@JonahPlusPlus
Copy link
Contributor

How about creating a ShadowMode enum (this would be a solution to #4372 as well)? Like AlphaMode but for shadows. If #4372 gets solved by applying the alpha mask to shadow, it might make sense to also have a mode for blending shadows together like AlphaMode::Blend does with textures. They could all be in one enum, so: ShadowMode::Opaque, ShadowMode::Mask(f32), ShadowMode::Blend and ShadowMode::None.

Pros: More control
Cons: If there is a default, you would have to set it every time in the material (Default for corresponding AlphaMode could be provided by making StandardMaterial.shadowMode be an Option<ShadowMode>, and using a default shadow mode if None)

@james7132
Copy link
Member

This should be fixed now that we're using prepass shaders for shadows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

No branches or pull requests

4 participants