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

Guidelines on transparency glitches and how to avoid them #4417

Closed
goatchurchprime opened this issue Dec 1, 2020 · 1 comment · Fixed by #5740
Closed

Guidelines on transparency glitches and how to avoid them #4417

goatchurchprime opened this issue Dec 1, 2020 · 1 comment · Fixed by #5740

Comments

@goatchurchprime
Copy link

Your Godot version:
3.2.3-stable

Issue description:
I was getting all kinds of glitches when I added an ALPHA field to my shader but only set it to not equal to 1.0 on rare occasions.

I spent quite a while going back and forth converting Spatial shaders into Shader Materials to find out if it was being controlled by a render_mode setting.
https://docs.godotengine.org/en/stable/tutorials/shading/shading_reference/spatial_shader.html#render-modes

While there are quite a few render_modes that relate to transparency, such as depth_draw_opaque, depth_draw_always, depth_draw_never, depth_draw_alpha_prepass, the transparency status is true if and only if the ALPHA value referenced in the fragment. It took me quite a while to work this out. It would be good to state this fact when transparency is first mentioned in the document so it is not such a mystery.

My example had a lot of surfaces popping in front and behind when I changed the direction of my view as the transparent objects were rendered in different orders. This should not have happened as all my objects were planar and parallel, so I suspect the sorting is by object centre point rather any AABB range.

The only guidance in the docs is to use transparency sparingly: https://docs.godotengine.org/en/stable/tutorials/optimization/optimizing_3d_performance.html#transparent-objects

I think there is a good argument for a tutorial as detailed as the spatial material tutorial to walk us through all the modes and glitches that we are likely to encounter with transparent materials, and tricks to avoid them.
https://docs.godotengine.org/en/stable/tutorials/3d/spatial_material.html

URL to the documentation page (if already existing):
https://docs.godotengine.org/en/stable/tutorials/shading/shading_reference/spatial_shader.html?highlight=depth_draw_alpha_prepass#render-modes

@Calinou
Copy link
Member

Calinou commented Dec 1, 2020

There's a page about this already: https://docs.godotengine.org/en/latest/tutorials/3d/3d_rendering_limitations.html#transparency-sorting

That said, there's also a bug with transparency sorting based on AABBs. This is being fixed by godotengine/godot#43507 and godotengine/godot#43506.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants