• Advertisement
Sign in to follow this  

Smoothing tiled terrain

This topic is 4320 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

Hi there :D I generate a random terrain tile. Then to generate adjacent tiles I pass the heights of the sides already generated. And randomly generating the rest. This works fine. However the problem occurs when I try smoothing. I smooth just by setting heights based on the surrounding 8 including itself over several iterations. (The exact method is new_height = own_height/2 + surrounding_eight/10) But I can't figure out how to do smoothing at the edges. If I don't smooth only the edges, then there are nasty spikes along them. I also tried smoothing the edges by using the 9 height square placed against the edge (but not surrounding as this would be out of range). But this of course is a hack and does not look correct (it creates the opposite effect to the spikiness, there are troughs. Although they are smooth.) Is there a solution to this?

Share this post


Link to post
Share on other sites
Advertisement
I don't like bumping posts but on a forum this popular they disappear very quickly.
You see.

Anyways I guess it could be done with some repeating function. But that would mean rewriting my code :-(

Although on my next project I will dispense with tilemaps as they are to strict...and have sort of patches of varying sizes.

Share this post


Link to post
Share on other sites
you say you use the surrounding eight to weight the new height of a tile in the middle of the terrain... why not use just the surrounding 5 for the side tiles, and surrounding 3 for the corners. You would need to give more weight to the surrounding tiles than you did for the surrounding 8 case though:

middle: 0.75 * selfHeight + 0.25 * (sumOfNeighborHeights / 8)
side: 0.75 * selfHeight + 0.25 * (sumOfNeighborHeights / 5)
corner: 0.75 * selfHeight + 0.25 * (sumOfNeighborHeights / 3)

(this is assuming your world is rectangular and you want to keep 0.75 of the original weight of each tile)

Share this post


Link to post
Share on other sites
the edges can still be found if you hunt... BUT it's much better than before, thanks :-D I did try something like that but I must of got the weights wrong.
I guess it's good enough for my current project (as you're flying a hovercraft over it so it shouldn't be too noticable)

Share this post


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

  • Advertisement