Advertisement

Representing height in top-down 2D simulation

Started by July 19, 2021 10:20 AM
0 comments, last by Pagi87 3 years, 4 months ago

Hi,

I'm trying to make an interactive terrain in 2D top-down perspective, imagine old pokemon or zelda games. The goal is to have per-pixel editable world with interactive elements. I have multiple layers of pixels (flat voxels?). See here:

Water flowing over ground and adding some elevated terrain

Each pixel has an absolute height. The normals are calculated from height difference between neighboring pixels. If height difference is ≤ 1, the pixel is interpreted as at an angle, otherwise the surfaces aren't adjacent. The only difference from a normal heightmap is a rule that if pixel Y is above X then height of Y must be at most 1 more than height of X. Due to this the front and top faces of the objects are displayed.

Now to my problem: when editing the terrain, I must iterate over all affected pixels (and more) to enforce the rule. In other words, I create the front faces manually to keep it looking consistent. This isn't so bad, but now if I wanted the terrain to erode under the water, I'd have to somehow enforce the rule there. I'm simulating the pixels using 2x2 pixel block cellular automata, so I'm not sure it's possible.

I thought about representing the height relatively (relative to pixel under or above). This would make adding walls, slopes etc. way easier. But without the aboslute height it would be inconsistent unless I also somehow delemit where surfaces end, or change the perspective.

So that's kind of where I am stuck. I want to make it intuitive to change the terrain by the user, and I want it to be impossible to break the terrain by editing it. Of course knowing terrain height would be good for jumping or pathfinding in a game. Any ideas on how to better represent or work with this data? Is there some research in this direction? Thanks for answers.

This topic is closed to new replies.

Advertisement