Advertisement

Triangle mesh generation from a heightmap?

Started by October 20, 2014 07:42 AM
3 comments, last by xoxos 10 years, 3 months ago

So far, I've been generating cubes (well, variable-height "cubes") from a straightforward perlin noise heightmap, but I'm getting a little stuck at producing a smooth triangle mesh instead of the "blocky" look. The obvious algorithms I can come up with to make a triangle mesh show obvious patterns in how the triangles are constructed. Does anybody have any good resources for this?

Thanks!

Just to be clear, are you trying to move away from the minecraft style to a more traditional landscape renderer? The reason I ask is that on your link you say "taking inspiration from Voxel Farm and Minecraft".

Advertisement

Just to be clear, are you trying to move away from the minecraft style to a more traditional landscape renderer? The reason I ask is that on your link you say "taking inspiration from Voxel Farm and Minecraft".

Yup, that's right. I already have cubes, but I want to get rid of the blocky look and produce a smooth triangle mesh. I'll still be taking inspiration from Minecraft, though, as well as Voxel Farm. The renderer isn't specialized for voxels (anymore), it's just rendering triangles. I just want those triangles to be more smooth, instead of staircasing everywhere.

I haven't tried this out, but my current plan is to keep the uniform grid (for terrain generation), and sample the heightmap at the center of each xz-square, as well as at each corner, then create a "square-based pyramid", but making the height of each vertex correspond to the heightmap at that xz coordinate.

The standard way to do this is to use a pre-calculated 'cookie cutter' mesh like this...

terrain_patch.jpg?psid=1

...with the x & z positions baked in, then read the height (y) from the heightmap. You then re-use this mesh over many sections of your heightmap, by offsetting x & z in the vertex shader.

It's always a good idea to make you're heightmap a power of 2 + 1 in width and height for easy LODing later on (the example patch above would use a 9x9 heightmap section).

excuse me for asking what may seem obvious, i got into 3d with triangles, which i found conceptually easy.. to me, a cube is 12 triangles.. can you point me to where you learned to render cubes before triangles?!

neither a follower nor a leader behttp://www.xoxos.net

This topic is closed to new replies.

Advertisement