- Home /
How to load a non-square terrain from ASCII file?
Hello!
The title says it all. I know that this is asked and answered before. And I have seen that people suggest to convert the ASCII file to 16-bit integer (raw) files and use heightmaps. But there is something that I can't figure out yet. The Unity heightmaps must be a square, and only in certain resolutions (513, 1025, etc.). So what if I need to load a rectangular terrain with a grid size of say 1082 x 823!? This must be something very easy to do, but I have spent the whole day to figure out it, and still no luck. So all I need is to read matrix of arbitrary size, preferably in ASCII, load it on Texture2D and then show it on a terrain in Unity. The texture2D part is because I need to do computations on the GPU.
The only thing that I can think of now is tiling a rectangular grid with squares ... Or not to use terrain at all, and use another object with a meshgrid.
Answer by tanoshimi · Feb 24, 2017 at 10:05 AM
Unity terrains are always square, and their heightmap arrays must always have dimensions that are powers of two + 1.
The only solutions to your problem are those you've already identified - use more than one terrain chunk to create your combined surface, or use a regular mesh.