# How can I make a cube with mountain surface only on top of the face in geometry node?

it's my first post in this community. English is not my mother language, so if there's any inappropriate word, let me know and I would fix it. Thanks!

Here's my question, I am making a cube with mountain landscape in geometry node with some limitations.

1. The landscape or the mountain surface only reveal on one face (personally set on top face)
2. The cube size can be adjusted (total height, length, width)

The main problem I am facing is that I don't know how to use the edge of the landscape I already created, and extend on one certain face and close it. So I can control the height of the object.

Here's some screenshots show my current geometry node.

Here's the completion that I expect.

Wish someone can help me answer this question!

You could start with a Mesh Primitive > Grid, then Mesh > Extrude it, and displace only the provided 'Top' selection.

Of course, the parameters exposed to the modifier are up to you.

To guarantee square subdivisions, the interface to grid construction is arranged as follows:

... which snaps the size to a whole number of squares, and subdivides accordingly. 'Resolution' is then measured in squares per Blender Unit. (1/Res is a Divide node, Sx*R+1 and Sy*R+1are Multiply Add nodes)

• Thanks! That looks much easier and adjustable! I will try later! Commented Jun 13, 2022 at 9:40
• Hi, @Hao-Wei.H ! See Edit, for one way of modifying the interface. Commented Jun 13, 2022 at 12:41
• Perhaps worth to note, this produces non-manifold geometry because there's no enclosing bottom floor - producing one is easy, just duplicate the top grid, don't displace it, join with the rest and Merge by Distance. Commented Jun 13, 2022 at 12:57
• Thanks a lot! I will try later! Wish u have a nice day! Commented Jun 13, 2022 at 13:11

you will get this:

First i split the edges so i can separate the top face, subdivide that top face for the "mountain building" and give a noise modifier for z-randomness (creates the mountains). With the multiply add vector node i mask only the x and y values and set the z values to 1 so that the cube will be closed, but only for x and y values which are either 1 or -1.

• Thanks! I will try my best to understand ur method! If there's any question, let me asks you more! Commented Jun 13, 2022 at 9:06

I was wondering how to produce n-gons on sides...

The Clamp Index node:

Basically if a side has 4 vertices, at first consider their indices to be:

 0, 1, 2, 3

Now spawn an n-gon with two more vertices, and consider their indices to be:

-1, 0, 1, 2, 3, 4

Now clamp the additional vertices to the former range:

 0, 0, 1, 2, 3, 3

If you clamp, output a 1; 1; 0 vector, which, multiplied by coordinates, will set Z to 0. If you don't clamp, output a 1; 1; 1 vector, which, multiplied by coordinates, will not change them.

Finally sample the positions taking advantage of deterministic vertex indexing in the Grid node: One side has the first indices, the opposite has the last indices, and perpendicular edges go in stride increments of a row length. Sometimes you need to reverse the order of indices to get the correct normal (aim for counter-clockwise winding).

• BTW, you probably don't want the n-gons. If you want to save on geometry, remember you're only saving half-1 faces internally/on export, due to triangulation. You may want to resign from Merge By Distance... Commented Jun 13, 2022 at 18:10
• Wow! that's a clean method! Thanks a lot for sharing your knowledge! Wish u have a nice day! @MarkusvonBroady Commented Jun 14, 2022 at 3:09
• @Hao-Wei.H just keep in mind usually you actually want the topology generated by Robin Betts' or Chris' answer. Commented Jun 14, 2022 at 8:39