- Home /
high resolution height map without loosing data
Hey
I was wondering how it would be possible to convert a low resolution height map to a high resolution one. I currently have a height map with a resolution of 513x513 but I'd like to scale it up to 2049x2049 to work on further details. But if I change the resolution in the terrain field, I actually use all the heights and so on which I changed earlier.
So I guess that I need to that through script but I couldn't figure out a good way to do that yet. Anybody an idea how to that?
Answer by raimon.massanet · Jan 07, 2014 at 01:58 PM
This is a tricky one.
If what you want is to "add" more terrain, I would do something like this:
     void ChangeTerrainResolution (int newResolution)
     {
         Terrain t = Terrain.activeTerrain;
         TerrainData d = t.terrainData;
         float[,] heights = d.GetHeights(0, 0, d.heightmapWidth, d.heightmapHeight);
         
         int previousResolution = d.heightmapResolution;
         d.heightmapResolution = newResolution;
         float[,] newHeights = new float[newResolution,newResolution];
         for(int x = 0; x < previousResolution; x++)
         {
             for(int y = 0; y < previousResolution; y++)
             {
                 newHeights[x,y] = heights[x,y];
             }
         }
         d.SetHeights(0, 0, newHeights);
     }
If you want to actually be able to "fill in the gaps", you will need to interpolate new height values and it will be somewhat more complex.
Answer by fred_gds · Jan 07, 2014 at 03:41 PM
Yeah I want to "fill the gaps" and that's actually where I'm struggling
Then I suggest that you export your heightmap to a raw file, change the image size using an image editor like Photoshop and re-import the heightmap. That way you don't have to code the pixel interpolation logic.
Your answer
 
 
             Follow this Question
Related Questions
Terrain Height Map Max Resolution is 4096? 0 Answers
What they did with terrain editor? 1 Answer
Unity splitting up terrains into equal heightmap resolution ones. 0 Answers
Add More Terrain 1 Answer
flatten Terrrain under object 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                