-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
VisualServer now sorts based on AABB position #43507
Conversation
Is this not sorting by the minimum position of the AABB, rather then the centre (of the AABB)? This is slightly confusing terminology used in the AABB - position is the minimums. You would have to calculate the centre (or you could store it separately if used multiple times, however the calculation isn't that involved). That said I can see the reasoning for this with off axis models and it does make sense. This also could potentially be beneficial for models that are animated moving from their origin. Unless this is violating any assumptions elsewhere (I'm not that familiar with the 3d renderer), clayjohn / reduz would have to confirm this. |
I had considered calculating the center but I'm not familiar enough with the renderer. On one side, I didn't want to add another variable to the struct for the transformed aabb center, on the other hand i wasn't sure if transforming the aabb position would break something else. |
Well, simple version, your line would just become something like:
Using the minimums (position) as you are will result in depth sorting errors skewed to one side in world space. Not that you won't get some visual errors using the centre, but that is unavoidable with such coarse sorting. |
Ah thank you @lawnjelly . I hadn't seen the transformed aabb size, I thought I'd have to add it. I will update the PR this evening |
ac2c912
to
ff71459
Compare
Well, a very very long evening |
The Git history seems a bit messed up as you reverted a commit by reduz, and amended your work into another one. |
Oh no 🤦 . Let me fix it |
this was causing issues with scenes where the origin of the objects was set for all objects to the center of the scene, making transparent objects sort improperly This work was kindly sponsored by IMVU Co-authored-by: RevoluPowered <gordon@gordonite.tech>
ff71459
to
8082e0e
Compare
Looking a bit closer I can see a similar calculation is done for shadows and for GI probes. Presumably they would also benefit, and there is a greater case for calculating the centre as a one off. Maybe we can ask reduz if he agrees with the general approach before going further, just in case he prefers using the origin, and any advice about calculating centre as one off? EDIT : Actually I have no idea why it is calculating depth for lights, rough depth sorting maybe, or for some cutoff with distance? It shouldn't need to render in depth order for transparency for shadow maps. |
@lawnjelly sounds good. I have tested this in the bistro scene and it makes the bushes render correctly,whereas before they would oddly overlap and flicker with one another in the area with the big tree (so it does work :) ). |
Will need a rebase.
Should this be changed in this PR too? (Once approved by @reduz as discussed) |
It's ok to merge as is imo (for 3.2 if reduz wanted to do differently in master). If we decided to add to another part too it could be a separate PR. |
@QbieShay @godotengine/rendering I can't remember, what was the consensus regarding what to do with the |
@akien-mga I don't remember any issues with this PR. As far as I recall, it was ready to merge. |
Was fine as far as I remember. |
Alright, I thought @reduz wanted to do something different for |
this was causing issues with scenes where the origin of the objects
was set for all objects to the center of the scene, making transparent
objects sort improperly
This work was kindly sponsored by IMVU
Co-authored-by: RevoluPowered gordon@gordonite.tech