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

Gizmos aren't Z-sorted properly with transparent surfaces #9935

Open
Zylann opened this issue Jul 27, 2017 · 24 comments
Open

Gizmos aren't Z-sorted properly with transparent surfaces #9935

Zylann opened this issue Jul 27, 2017 · 24 comments

Comments

@Zylann
Copy link
Contributor

Zylann commented Jul 27, 2017

Godot 3.0 alpha1 official
Windows 10 64 bits
nVidia geforce 940M

It depends on the viewing angle, gizmos get randomly drawn behind or in front of transparent surfaces. In the screenshot, the blue plane is slightly transparent:

image

@bojidar-bg
Copy link
Contributor

Happened similarly on 2.2, AFAIR.

@reduz
Copy link
Member

reduz commented Jul 28, 2017 via email

@reduz
Copy link
Member

reduz commented Aug 25, 2017

actually judging by your bug, i have no idea what's going on. If you can make a very simple test scene (in case it was not fixed already) i will give it a check

@HummusSamurai
Copy link
Contributor

Also I am not sure if this is the right place to mention this, but the gizmos are also hidden by fog which is inconvenient sometimes.

@reduz
Copy link
Member

reduz commented Aug 26, 2017

@Zylann This should be properly working now (just fixed it), but please reopen if you see something different
@HummusSamurai This won't change. You can disable environment if you feel gizmos are inaccessible in the viewport menu.

@reduz reduz closed this as completed Aug 26, 2017
@Zylann
Copy link
Contributor Author

Zylann commented Aug 26, 2017

Looks like it's fixed:
image

@Zylann
Copy link
Contributor Author

Zylann commented Aug 29, 2017

Sorry, I reopened the initial scene, the problem is not fixed...
I shot a video to better explain what happens:

https://www.youtube.com/watch?v=16nTnP02JIw&feature=youtu.be

Turning environment off doesn't fix the issue:

image

Turning also shadows off doesn't fix it either:

image

My graphics card shown in the log:
GL 3.3 contextOpenGL ES 3.0 Renderer: GeForce 940M/PCIe/SSE2

@akien-mga akien-mga reopened this Aug 29, 2017
@reduz
Copy link
Member

reduz commented Aug 29, 2017 via email

@Zylann
Copy link
Contributor Author

Zylann commented Aug 29, 2017

No, it's just a transparent quad

image

@reduz
Copy link
Member

reduz commented Aug 30, 2017

also if you can make a simple reproduction demo, that would be great

@Zylann
Copy link
Contributor Author

Zylann commented Aug 30, 2017

Well, I tried earlier^^" but only repro in this project. I can try to simplify it

@Zylann
Copy link
Contributor Author

Zylann commented Aug 30, 2017

GizmoDrawOrder.zip
Simpler project
image

@reduz reduz closed this as completed in 8f30c52 Sep 1, 2017
@Zylann
Copy link
Contributor Author

Zylann commented Sep 4, 2017

Sorry to popup again, but... it's better now, however some rogue gizmos still don't sort consistently:

(light arrow and cube bounding box)
image

@toger5
Copy link
Contributor

toger5 commented Sep 4, 2017

looking at the commit.
there is probably just this missing for the light:

 -		gizmo_hl->set_flag(SpatialMaterial::FLAG_ONTOP, true);
 +		gizmo_hl->set_on_top_of_alpha();

(maybe)

@mss1451
Copy link

mss1451 commented Mar 15, 2020

Here is a MeshInstance with transparency flag. Node specific gizmos don't appear on top of it unless the render_priority of the material is -128. As seen in the picture, transformation gizmos render just fine.

gizmo1
gizmo2

Here is a MeshInstance that has a screen-reading shader. Again, can't see gizmos regardless of the depth.

shader_type spatial;
void fragment()
{
	ALBEDO = texture(SCREEN_TEXTURE, SCREEN_UV).rgb;
}

gizmo5

@markusneg
Copy link
Contributor

markusneg commented Jun 19, 2023

Sorry for digging up this old chestnut again, but the bug is still around in 4.0.3-stable. I also had it in 3.x. It's quite easily reproducible: just set transparency of a StandardMaterial3D to another value than TRANSPARENCY_DISABLED and observe gizmos disappearing. This is an example project featuring a CollisionShape3D gizmo disappearing in front of a box-shaped MeshInstance3D: gizmos_zordering_alpha.zip.

@Calinou
Copy link
Member

Calinou commented Jun 20, 2023

This cannot be resolved as per the 3D rendering limitations around transparency sorting.

Some workarounds have been proposed such as godotengine/godot-proposals#2138, but they come with downsides on their own. Order-independent transparency isn't something we can rely as a baseline feature for rendering the 3D editor, as it's very slow.

@clayjohn
Copy link
Member

Testing locally, I actually can't reproduce the issue anyway. The gizmo appears to sort fine

Screenshot from 2023-06-20 10-13-51
Screenshot from 2023-06-20 10-13-48

@markusneg
Copy link
Contributor

markusneg commented Jun 20, 2023

Testing locally, I actually can't reproduce the issue anyway. The gizmo appears to sort fine

In your second screenshot the CollisionShape3D gizmo isn't visible although being in front of the cube. I should have chosen a better albedo in my test project. Those red-blue-green "spatial manipulation gizmos" never disappeared in my case.
The vanishing gizmos are actually much more noticeable when environmental meshes (like a huge floor) have transparency enabled because then all the gizmos disappear. This way it's very hard to inspect and manipulate e.g. collision shapes or lights.

This cannot be resolved as per the 3D rendering limitations around transparency sorting.

Some workarounds have been proposed such as godotengine/godot-proposals#2138, but they come with downsides on their own. Order-independent transparency isn't something we can rely as a baseline feature for rendering the 3D editor, as it's very slow.

Thanks for the information. Although I don't fully understand why the red/green/blue manipulator gizmos are ordered correctly.

@clayjohn
Copy link
Member

I see. So what you want is for all the gizmos to always appear on top? Right now they are sorted in the transparent pipeline. So if they are behind an object, they won't be visible. Is it correct that you would like them to be visible all the time, regardless of whether they are in front or behind an object?

@markusneg
Copy link
Contributor

I would expect them to be visible if they are in front of a geometry. I.e. if nothing is between the object/gizmo and the camera.

@clayjohn
Copy link
Member

In my screenshot the physics shape is behind the cube and it is correctly sorted so only the portion sticking up above the cube is rendered.

So to clarify what you are reporting:

  1. You are saying that gizmos (except the translate/scale/rotate) are always appearing behind transparent objects (even when they should be in rendered in front
  2. You aren't suggesting that gizmos be always on top

Is that correct now?

@Calinou
Copy link
Member

Calinou commented Jun 20, 2023

Note that if you actually desire this, you can already choose select node gizmos to appear always on top using the View > Gizmos menu at the top of the 3D editor viewport. Click on a gizmo in the list until it has a "half open" eye icon. This means it uses the X-ray visibility mode. This will effectively resolve transparency sorting issues by not performing any sorting for the transparent object in the first place.

The only other way to resolve the transparency sorting issue is making the gizmo materials opaque and using another form of transparency instead, such as alpha scissor with dithering. This could use a checkboard pattern to look better for thin lines compared to interleaved gradient noise. This can also improve performance slightly if you have large gizmos covering the viewport.

@markusneg
Copy link
Contributor

markusneg commented Jun 21, 2023

On my machine the gizmo is disappearing, regardless of which side of the cube it's on:
gizmos
@clayjohn: ad 1) yes, ad 2) yes, I suggest them being visible if they are not hidden by geometries and (as I now learned) being visible even when hidden when the "half open" eye is active for X-ray visibility mode.
@Calinou: the X-ray visibility mode of gizmos doesn't change the behavior in my gif

Edit: changed "ad 2)" to "yes" because I spotted clayjohns "aren't"

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