2
$\begingroup$

I've been playing with geometry nodes recently, and I'm finding it tricky to get an optimised mesh.

I'm generating a simple block terrain, however, the problem is the mesh instances build on top of each other. I attempted to use Boolean Union and proximity but that gives patchy results and also melts the CPU.

Is there a cleaner way to remove mesh instances which aren't visible or a way to calculate two faces next to each other and remove them?

Attached is an image of the underside to show the problem

Hope that makes sense, thank you

Top view

Bottom view

$\endgroup$

1 Answer 1

1
$\begingroup$

I assume from your example that you are instantiating cubic shapes here...

Try the following:

Node tree

  1. First convert the instances into a mesh with Realize Instances and capture the positions of the points with Capture Attribute.

    Capture positions

  2. Then scale the elements a little bit smaller.

    Scale the elements

  3. Remove all horizontal faces, except the ones at the top. To do this use the node Raycast and send a ray from the center of the faces in the direction $(0,0,1)$ (pointing upwards). If you don't have a Hit it means it's an intermediate face and can be deleted. In addition, combine this selection with the faces whose normals are also pointing upwards, so that the side faces are not additionally selected.

    Remove horizontal faces

  4. Then send a ray from the remaining faces in the direction of the normals. However, move the position a little bit in the direction of the normals, so that you don't hit your own face. Note that the Ray Length here must be smaller than the length of a single object (!). If you have a Hit, it means that the face was originally adjacent to a face of another previously instantiated object and can be deleted.

    Remove adjacent faces

  5. Finally, restore the positions of the original points and apply the node Merge by Distance to merge the remaining mesh.

    The final result


(Blender 3.2+)

$\endgroup$
1
  • 1
    $\begingroup$ That is a smart variation of how it's usually done in video games ! $\endgroup$
    – Gorgious
    May 16, 2023 at 12:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .