Change Terrain Heightmap Resolution without Resizing Terrain
Inspector Behaviour (Desired Effect)
When I change my terrain's heightmap resolution through the inspector via:
Terrain -> Terrain Settings -> Texture Resolutions (On Terrain Data) -> Heightmap Resolution,
the resolution of my heightmap is increased without the terrain visibly changing.
Script Behaviour (Unexpected Effect)
However, when I try to recreate this behaviour via script like so: Terrain.activeTerrain.terrainData.heightmapResolution = 1025;
The terrain not only changes heightmap resolution but also size, with very strange effects like repeating textures etc.
How can I resize the heightmap via script WITHOUT any visible changes to the terrain, exactly as done via the inspector?
Essentially, I want to produce the exact same change produced by selecting the following, but via a script:
Lookin' for the same thing. Found a solution for this yet?
Answer by subliminal_1 · Dec 30, 2020 at 02:07 AM
I'm having the same problem. I can generate a scripted terrain at a heightmapScale of (1, 200, 1), but with terrain at size 4096 the heightmapResolution must be 4097. Then I can manually lower the heightmapResolution in the editor to say, 257 which then works fine after applying the "resizing" button in the Unity Terrain editor. Then I see (via script) that the heightmapScale has been reset by the editor's resizing to the value (16, 200, 16). This all makes sense since 16*256 + 1 = 4096 + 1.
However, my problem is that I have to do this manually for all of my terrain tiles. Why can't Unity support the editor's resizing button with a scripting function? Or simply provide a scripting function to map lower resolution heightmaps onto terrains? Is some way to do this?
Did you ever find a solution for this? I'm having the exact same problem
Someone knew how it was implemented, see this thread here