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

Low-alpha transparent objects don't cast shadows even with opaque pre-pass #31661

Closed
Cykyrios opened this issue Aug 25, 2019 · 5 comments
Closed

Comments

@Cykyrios
Copy link
Contributor

Godot version:
3.2.dev 6d6d437

OS/device including version:
Linux Mint 19.2 x86_64

Issue description:
Shadows of objects with a transparent material and Opaque Pre-pass enabled disappear when alpha drops below 0.1. In the picture below, on the left, alpha is 0.099 (down to 0), on the right it is 0.1 (up to 1).
editor

Steps to reproduce:

  • Add a directional light to the scene and enable shadows.
  • Create a spatial material with the transparent flag and depth draw set to opaque pre-pass.
  • Play with the albedo alpha, any value below 26 (or 0.1 when normalized) will cause the shadow to disappear.

Minimal reproduction project:
TransparentShadow.zip

This project contains a propeller which can spin at high speeds. A MultiMeshInstance is used to instance several duplicates with reduced opacity to create a "volumetric motion blur" effect.
Opacity of each instance depends on the number of instances, a single instance is fully opaque, and 100 instances results in an alpha value of 0.1. Any number of instances above that will cause the shadows to disappear.
While in the editor, the original mesh is visible, setting the PropMat material's alpha to values lower than 0.1 will also exhibit the issue while in the editor.

Unrelated to this specific issue but still about transparency, the picture below shows discrepancies to the rendering of transparent objects when depth draw is set to opaque only (left) or opaque pre-pass (right), should I open a new issue for this or is it expected behavior?
ingame

@clayjohn
Copy link
Member

The threshold for alpha when using opaque prepass is indeed 0.1, it is found here:

state.ubo_data.opaque_prepass_threshold = 0.1;

Opaque prepass is only supposed to capture the opaque parts of a partially transparent mesh, hence the cutoff of 0.1. I am not sure why 0.1 was chosen. Maybe it could be made configurable in the material?

@clayjohn clayjohn added enhancement and removed bug labels Aug 25, 2019
@Cykyrios
Copy link
Contributor Author

It does make sense not to render shadows of almost invisible objects, but it would be nice if it was documented or configurable.
Would you be aware of another way to render such shadows (preferably with low alpha as well)? Or is it a current limitation of transparency rendering?

@clayjohn
Copy link
Member

Right now I don't think there is any way to render transparent shadows below an alpha of 0.1.

But it should be possible to add a way to configure this threshold.

@Calinou Calinou added this to the 4.0 milestone Feb 6, 2022
@Calinou
Copy link
Member

Calinou commented Feb 6, 2022

Should the alpha scissor threshold stored in the material be reused as the shadow alpha threshold for opaque prepass?

We can add another property to the material, but I'd prefer if we reused existing properties when it makes sense to do so.

@clayjohn clayjohn modified the milestones: 4.0, 3.5 Nov 13, 2022
@clayjohn
Copy link
Member

This was implemented in #45372

Now you can use a lower threshold by overriding it with alpha scissor

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

4 participants