So, I’ve been playing around with ideas for coding my 2D top-down terrain. See below for the originating thread:
I don’t know if it’d be possible, but would I be able to use heightmaps in a 2D fashion, coding individual pixels for elevation? I’m going for procedural generation of maps, and, theoretically speaking, I imagine I could use a heightmap for coding 2D terrain, because heightmaps can be procedurally generated. Unity can assign a color to individual pixels, but can you assign values to individual 2D pixels, given a criterion of conditions?
Any ideas. Once I figure it out, I’m going to post it as a free asset, regardless, so have at it if you guys have ideas for how to achieve this, if it’s possible.
It’s math. A height map is basically a value for a coordinate. You just need to find how to convert color to height or the other way around, but yes, it’s doable. Without more info, it’s hard to give you advice on how to proceed.
I plan of generating a heightmap via procedural generation, but stopping at the point at which it would be used for 3D terrain. After that, using pixel data to assign a given elevation, then hopefully being able to throw a sort of topographical map that can be toggled on and off. Obviously, there’ll be textures and everything on the 2D map, but that’s pretty much the gist of what I’m trying to achieve.
By pixel data do you mean a color or value for a pixel on the height map? If so, then you can just generate elevation directly. There are lots of ways to generate values instead of colors for a height map. You can try looking at Perlin noise generator for example. It’s one of the most used. It gives a float/decimal value per pixel.
From my understanding, what you described was generating an image, to use as heigh map. Then converting it to values table, which you will then convert back to some kind of image. You can just get a values table/array directly and skip the first part, since it’s unnecessary.