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

Materials set to "Transparent" have strange layering (ex: background on foreground) #21050

Closed
aaronfranke opened this issue Aug 15, 2018 · 9 comments

Comments

@aaronfranke
Copy link
Member

Godot version: 3.1-dev with Mono, including latest c627f3a and others such as 80a8636 (I've been having this problem for awhile it's not new)

OS/device including version: Linux Xubuntu 18.04.1 64-bit, Mono 5.14

Issue description: For some reason, if I enable the "transparent" property of a texture, the background sometimes appears over the foreground. It's a really strange effect.

trans1

trans2

If I disable "Transparent", then the mesh renders correctly, however, anything with transparency in it (like if I wanted to make a glass block) appears white instead.

Steps to reproduce: Have a mesh with textures overlaying and enable the transparent property of the material. In my case I have a code-generated Mesh via SurfaceTool.

@fire
Copy link
Member

fire commented Aug 15, 2018

Did you try DEPTH_DRAW_ALPHA_OPAQUE_PREPASS ?

See https://godot.readthedocs.io/en/3.0/tutorials/3d/spatial_material.html#depth-draw-mode

@aaronfranke
Copy link
Member Author

@fire That works, how come it's not enabled by default? Perhaps it should detect if "Transparent" is enabled and automatically use that setting if so.

@CptPotato
Copy link
Contributor

CptPotato commented Aug 17, 2018

Sounds like transparency sorting to me. (transparent objects are sorted back to front based on their origin).

There is no perfect fix for this. Using 1 bit alpha (alpha testing, not sure what the name is in godot) is one way but you'll have to put up with sharp borders and aliasing.

@aaronfranke
Copy link
Member Author

So... an update on this issue. My brother and I recently updated our main project to Godot 3.2 alpha, and we can confirm that this issue is still present.

However, I will note that a) It can be worked around if we fiddle with it, and b) It doesn't ever occur on GLES 2, so it's possibly a GLES 3 specific issue. Since GLES 3 isn't being worked on anymore due to being removed in the future, I suggest bumping this to the 4.0 milestone.

Untitled

@Calinou Calinou added this to the 4.0 milestone Nov 4, 2019
@clayjohn
Copy link
Member

clayjohn commented Nov 5, 2019

Im not sure this should be an open issue. The solution is to use DEPTH_DRAW_ALPHA_OPAQUE_PREPASS

Otherwise it's just a limitation of 3d rendering. We aren't going to do a prepass on all transparent objects because it is expensive and usually unnecessary.

@tcoxon
Copy link
Contributor

tcoxon commented Jan 29, 2020

I think this issue is back in 3.2.

sprite3d-shadow-depth.zip

In this reproducer I have two transparent Sprite3Ds set up with DEPTH_DRAW_ALPHA_OPAQUE_PREPASS. In the foreground is a blue one, set to not cast shadows, and in the background is a red one that does cast a shadow. The blue sprite is positioned to occlude the red sprite.

When you run the project in 3.2, you can see the red sprite through the blue sprite. You can also see this in the editor by lining up the camera. Strangely, it only does this for certain angles of directional light?

3.1.1 was unaffected.

I think this is related to #30764, the fix for #30673. It has a pretty major impact on my project.

@realkotob
Copy link
Contributor

I can confirm this is happening on the latest 3.2 stable.

@clayjohn
Copy link
Member

clayjohn commented Jun 26, 2020

@tcoxon Can you run it again in 3.2.2? I can't reproduce the issue.

edit Nevermind, I can reproduce it now. I will make a fix shortly.

@Calinou
Copy link
Member

Calinou commented Nov 1, 2020

This is a limitation shared by most real-time renderers out there: https://docs.godotengine.org/en/latest/tutorials/3d/3d_rendering_limitations.html#transparency-sorting

Using opaque pre-pass usually solves this, but there are known bugs like #43253. I'll close this issue in favor of other reports that are specifically about opaque pre-pass.

@Calinou Calinou closed this as completed Nov 1, 2020
@aaronfranke aaronfranke closed this as not planned Won't fix, can't repro, duplicate, stale Dec 4, 2023
@YuriSizov YuriSizov removed this from the 4.0 milestone Dec 4, 2023
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

10 participants