-
-
Notifications
You must be signed in to change notification settings - Fork 22.8k
Improve render sorting for alpha pass #106593
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
base: master
Are you sure you want to change the base?
Conversation
I don't know why the docs check failed for Linux / Editor w/ Mono given that it is giving me a completely incorrect sorting_stacked_offset that isn't an int so I wonder if the system is confusing sorting_offset and sorting_stacked_offset so I don't know what the problem mainly because |
I see this adds a new property that acts as a secondary sorting offset for objects whose depth is identical (which acts different to the existing one). Is there a proposal tracking it? This should be discussed in a proposal to make sure there's an established need for it.
You need to reorder the property in the generated class reference to follow alphabetical order. I suggest running |
I realized the property methods where set to float by accident |
75dc7dc
to
267a6e5
Compare
96eb98c
to
d816f3d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you provide some details about why you added sorting_stacked_order
it seems to solve the same issue that the existing sort_offset does. We discussed doing something similar to sorting_stacked_order
but decided to go with the sort_offset instead, although I can't remember the exact reason.
servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h
Outdated
Show resolved
Hide resolved
servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h
Outdated
Show resolved
Hide resolved
So in my use case I am implementing a 3D UI for VR Talking about the problem its also disgusting to use a float in order to control z ordering |
Coming from the perspective of 2.5D game (flat entities rendered in transparent pass in 3D environment): The |
I have updated my test |
@clayjohn I have implemented a new sort key for transparent explicitly and for stacked order I just flip the sign bit so the order works the only thing I am a bit questionable on is if I should just do bitwise equal for the same depth check it will work for the submeshes and and other stuff because they share an owner but for meshes that are literately on top of each other it could brake given how they got on top of each other to be honest I am sort of 50 50 on it |
Also this system is the precursor to transparency groups all you would need to do for a group is a system to make all objects within the group use the same depth (user set, closest object, farthest object) doesn't really matter just needs the depth for the point of injection and then the user uses stacked order to actually handle the order within the group |
servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h
Outdated
Show resolved
Hide resolved
Now uses a single sort key for transparent sorting |
@clayjohn I believe this is done now unless you can think of anything I could be missing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally, it works as expected in Forward+/Mobile.
I think the new property makes sense, as it's useful for 2.5D usage with composited Sprite3Ds.
There should be a configuration warning when the property is set to a value other than 0
when using the Compatibility rendering method though, as it's not implemented there.
I should have caught this earlier (Calinou's comment made me realize), but this same change should be added for the Compatibility renderer too. The code is very similar to the mobile and forward+ renderers, so the implementation can basically be copied over. |
I brought this up in today's rendering meeting and the team expressed a bit of concern about adding yet another tool to manage rendering order in the transparent pipeline. Right now we have render priority, sort offset and aabb center. We want to avoid a situation where there are multiple competing solutions to the same problem. We ran out of time before we could fully discuss the problem and whether Unfortunately since this PR didn't link any of the related proposals, we didn't have those in front of us to properly judge whether the current tools available are enough for users. I think we will need to discuss this again at the meeting in two weeks with the proposals in hand to properly decide what to do. Personally I am leaning towards merging the implementation in this form (once Compatibility renderer support is added), but I want to make sure everyone is happy with that approach. For future reference, here are the proposals that relate to this: |
I did add a MSVC warning ignore in cowdata because after rebase I was no longer able to compile locally because of it. I did update MSVC so I don't know if it was a problem was with a recent commit or a new thing with the newer version of MSVC |
That's fine, |
@clayjohn I added compatible render I believe at this point the pr is completely ready |
I think the thing that would make it easier is transparency groups where you put all of the objects in a group which makes them all the same depth and with that you set it to use the closest object depth farthest mid point or average. So in your use case each layer/plane you want you put them all in a group I do think a definable pipeline for depth to override how it works on a per object basis would be nice which could even be the system used to make the transparency groups |
Should I just already add the system for transparency groups which would make the use of stacked sorting order. I would add the nearest, farthest, average which is the distance chosen for the group of transparent objects |
Made sorting more deterministic for transparent objects by making it fallow
Sorting Order
Also added stacked sorting offset for when the depth is the same but a user wants to render multiple layers of objects but don't want it effecting neighboring objects
After fix


gizmos no longer mess with sort
Before fix inconsistent sorting and flashing


gizmos mess with sort
The project I made for testing
project.zip