-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Depth sorting for node faces #11696
Depth sorting for node faces #11696
Conversation
Tagging @appgurueu @Wuzzy2 @sfan5 @Andrey2470T @hecktest |
I wonder if and how it is supported that a node's texture is tiled within the node. I replaced texture tiling with clamp-to-edge to catch cases of using tiling incorrectly, and I wonder if this case is a legitimate use of textures or just reliance on a bug. |
I've now decoupled decision on tile merging from texture tiling and reverted changes to texture tiling, which fixed the artifacts above, and still allowed transparent water and ice to render correctly. I've also added support for oversized nodeboxes, up to 3 nodes in each direction, which fixed a number of artifacts when looking through weird-shaped stained glass. |
Thank you for sharing. I have tried the server, and in some places there is a lot of transparent geometry to render. I can do some optimizations, but correct transparent rendering currently should be expected to be 10 times slower compared to solid rendering due to the extra CPU operations, not using Z-buffer, extra drawcalls and lots of material swaps causing performance drop on the GPU. At some point, optimization will require a rewrite of the material system. |
I've managed to go from 2 to 8 FPS on a scene in Boom with 200 nodes distance by only depth-sorting meshes within 75 nodes from the player. This causes minor effect of objects "swapping" or "popping up" at a distance as map blocks switch into full depth sorting mode, which plays into an overall story of "level of detail" when rendering the map. That said, there are still scenes in Boom that cause 2-4 FPS on my laptop at 200 nodes distance due to the sheer amount of falling transparent water. |
Now after the fix FPS has become higher on that server, even a bit higher 8 (varies within 10 - 13 FPS). Thanks for the fix. |
So is this bug irrelevant to this PR if you told me you didn't discover this on Tunneler's Abyss? I don't see its display on any another builds, but only in your one. I doubt this problem concerns to my hardware or video drivers. So, I can conclude this bug hides somewhere in your PR's code. |
I can confirm the bug, but it does not occur in 100% of cases. |
@Andrey2470T The bug was caused by an uninitialized memory read due to reallocation inside std::vector and the reference to the current box not being adjusted. It should be fixed now, and I've also added a few improvements to the code to avoid performance problems in edge cases. |
Could the BSP tree be made to take into account semitransparent particle & entity triangles? |
I would not say it is impossible, but it is a significant step up in complexity. There are multiple reasons for this:
|
Is this PR ready for merging? In any case, I didn't found any other noticable bugs, except which I reported about before and which already fixed. The only current downside is a lower FPS, however generally it is not critical and quite playable. |
This PR is ready to be reviewed by the core developers, there is no known technical debt / problems to be fixed. |
Bump. This is very important for semitransparency to work among nodes. The rendering glitches before this are pretty critical. |
@x2048 please rebase this branch on master so it can be compared to recent Minetest easier in terms of performance. |
Yes. I have issues: https://forum.minetest.net/download/file.php?id=25605 Transparent nodes besides other transparent nodes.=> The face is totally transparent. |
@runsy Can you give more detail on how to reproduce it? |
@x2048 seems it was taken from https://forum.minetest.net/viewtopic.php?p=406861#p406861 which appears to be regular mte and not this PR? follow up https://forum.minetest.net/viewtopic.php?p=407177#p407177 |
You're the one not keeping it real by arguing using the worst case (the only valid point I could see is griefers abusing this to lower FPS of other players in certain areas). If semitransparent nodes are assumed to be randomly distributed and rather sparse, this worst case definitely won't come into play. To give another example: Quicksort has a worst-case complexity of O(n²) as well, yet it is widely used, because the expected average running time if randomly picking pivots is O(n log n). Granted, in this case the complexity isn't determined by the data (the list) being "average", but rather the random not constantly picking the worst pivots. |
So, what is the final decision? It is necessary another dev to review this. |
@runsy The distance of depth sorting will become adjustable, which will allow the client to avoid performance drops. The PR goes in, and we start work on OIT that would support both map, entities, clouds and particles. And be less sensitive to edge cases. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
@x2048 if you want this merged there's only two open comments from my side. |
Basically instant OOM while facing the following building near the spawn of Blocky Survival (mt.krypticbit.com 30005). This definitely need investigation. Surrounding transparent nodes (possibly customized):
|
@SmallJoker good stuff, thanks for sharing |
Due to index variable being u16 loop would lead to OOM and crash when a mapblock has more than 64K triangles.
@SmallJoker OOM should be fixed now. |
Setting name: transparency_sorting_distance
@runsy i've now added a setting |
Coolz Thankz. |
Seems to be faster and smaller code than passing by const-reference
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.
Works. Code adjustments are welcome.
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.
Gave it a quick test, I don't have any intensive test scenes so I trust @SmallJoker with that.
This PR aims to implement correct painter's algorithm for transparent nodes on the map.
This PR supersedes parts of #11130 and fixes most of cases of transparency problems (including transparent nodebox nodes at the cost of performance).
Handling Transparent Nodeboxes
In order to render overlapping nodeboxes correctly, this PR splits each nodebox at the edges of other nodeboxes along the same axis. This process produces a significantly larger number of 'atomic' nodeboxes that are guaranteed not to overlap, and may impact overall rendering performance. The total number of nodeboxes (defined + produced) is currently limited to 100.
To do
This PR is Ready for Review and testing
How to test
Use a combination of semi-transparent nodes such as:
Transparent nodes should be rendered correctly with minimal temporary artifacts from all angles.