Jump to content
  • Advertisement
Sign in to follow this  
Ben Foppa

Triangle mesh generation from a heightmap?

This topic is 1510 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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".

Share this post


Link to post
Share on other sites

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.

Edited by Ben Foppa

Share this post


Link to post
Share on other sites

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).

Edited by mark ds

Share this post


Link to post
Share on other sites

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?!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!