Generate only the necessary number of faces to convert a 2D heightmap to a 3D surface

I have an advanced question that should be interesting to tackle, involving geometry nodes and procedural generation. Let’s say I have a texture, can be an image or procedural noise, it is either a normal map or a height map. I want to turn it from 2D to 3D so it pops out, use it to offset the geometry of a simple object, for simplicity’s sake let’s say a cube or flat plane though I plan on using it to obtain corridors with a more defined shape.

Normally what you do is simple, Cycles micro-displacement already does this: You subdivide your mesh a lot to give it many vertices then use your heightmap to displace them. But to get any decent results you need a lot of vertices: This is slow to compute and uses a lot of memory, which makes it not ideal for many practical use cases, Cycles renders using adaptive subdivision can be very slow and use a lot of RAM before rendering starts.

I’d like to know if there’s a way to create geometry only where necessary based on a desired level of detail, using the difference between pixels in the height map. If a chunk of the image is flat, no new vertices are added unnecessarily… vertices are instead generated when a turn is sharp enough to require them, density depends on how abruptly pixels in the heightmap change from their nearby neighbors. Is there a way for geometry nodes to scan a grayscale texture and create geometry as needed based on the content?

The halfway solution I’m aware of is to first subdivide your plane a lot, apply the displacement, then use a decimate modifier to merge faces with a low angle difference. This should produce the end result to what I’m imagining. Only problem is you still waste resources generating the original high-poly surface: You could do this once for whatever level of detail allows you to not run out of RAM then apply the modifier to save the decimated mesh, but then it’s no longer procedural and making changes in the future won’t be possible without repeating the process.

I think this is the best solution so far, unless you want to create a plugin that does the same thing in a clever way…

Geometry node isn’t the best tool for that, and it’s very likely that you’ll have to generate all the polygons then find strategies to reduce the polycount.
Because, given how GN works, it’s impossible to know if a surface is flat before generating that surface.
But maybe a py script could pre-process the image to look for these flat surfaces and eventually generate the needed geometry.
I’m not sure if the result is worth the effort if you ask me…

Maybe something like this ??

Yes: The tricky part is Blender would need to analyze pixels in the image, determine which areas contain sharp transitions between black and white, and generate vertices only below a certain level of smoothness. Understandably it’s a bit complex and unlikely to work out of the box without an advanced plugin.

An alternative I was looking into is whether I can use a noise texture in geometry nodes to generate separate islands initially (panels, bricks, etc) which can then be extruded and smoothed separately: I’m working on something procedural so using noise for geometry is even better. I saw some amazing concepts with geometry nodes in that regard but still haven’t figured out how they’re done: Planning to watch a few tutorials on procedurally generated scifi panel walls which will hopefully enlighten me.

Well that’s probably possible, keep in mind that any texture need something to be evaluated. In shader node it’s the surface, in geometry node it’s some vertices / faces / edges…
If you have only one vertex you’ll get one sample of a texture at a position.

Of course it depends on the case but using textures could mean a lot of geometry to sample from.

But say you want to generate some brick wall pattern it might be simpler to start with a brick and make an array of it …

Yeah it’s better to study GN through tutorials and get a good understanding of the concepts, then see how you would solve a particular problem, rather than thinking about solutions without knowing the tools …

1 Like