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

Avoid rendering invisible faces of simple nodeboxes #12262

Merged
merged 6 commits into from
May 4, 2022

Conversation

x2048
Copy link
Contributor

@x2048 x2048 commented May 2, 2022

This PR adds basic infrastructure to render partial cuboids and adds optimizations for simple adjacent nodeboxes of the same type (snow, slabs, stairs etc.)

Fixes #6409.

To do

This PR is Ready for Review.

How to test

Scenario 1

  • Create a V7 world in MTG or an MCL2 world
  • Start the game and find a snowy biome with 'slab' snow
  • Use noclip or wireframe to see through the blocks
  • Notice that occluded snow faces are not rendered

Scenario 2

  • Place slabs in MTG in various configurations and combined with solid blocks
  • Use noclip or wireframe mode to see through the blocks
  • Observe that faces touching solid blocks or adjacent slabs are not rendered.

@rubenwardy rubenwardy added the Roadmap The change matches an item on the current roadmap. label May 2, 2022
@sfan5 sfan5 self-requested a review May 2, 2022 22:07
src/client/content_mapblock.cpp Outdated Show resolved Hide resolved
src/client/content_mapblock.cpp Show resolved Hide resolved
* Meaningful variable names
* Comment improvements suggested by sfan5
* Optimize parameters of getNodeBoxMask
@sfan5
Copy link
Member

sfan5 commented May 3, 2022

Tested and works. This is a good start and we can almost merge this immediately.

I think it's worth expanding on this approach instead of directly going for a (more complicated) generic duplicate vertex removal algorithm.
I was thinking of something like this:

  1. The engine precalculates the area covered by each node on each side.
    I suppose an AABB would work here as an approximation but strictly speaking it needs to be multiple.
  2. Whenever a box is rendered that touches a node border, the code can look up whether the face is occluded by a (larger or equal size) neighboring face.

@x2048
Copy link
Contributor Author

x2048 commented May 3, 2022

I agree with the direction, and I have some ideas about how to optimize internal faces that could be placed in a new PR.

@x2048 x2048 closed this May 4, 2022
@x2048 x2048 reopened this May 4, 2022
@x2048 x2048 merged commit cc56ebd into minetest:master May 4, 2022
@x2048 x2048 deleted the nodeboxes branch May 4, 2022 21:45
@x2048 x2048 mentioned this pull request May 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@ Client / Audiovisuals One approval ✅ ◻️ Performance Roadmap The change matches an item on the current roadmap.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Efficient ways to render layered nodes like default:snow (discuss)
4 participants