- Home /
Procedural terrain bigger than I set it, heightmap slightly off
Hello,
I'm about to procedurally create a terrain of the size 120x120. My problem is, the end product turns out to be 480x480
Also the height map isn't set right. That little edge isn't supposed to be there. The height map data is, to my knowledge set right. Here's a Debug.Log:
heightMap[0,0] = 0.9363611
That should be the top left corner of the terrain in the attached screenshot.
This is how I create the terrain:
int chunkSize=120;
float[,] heightMap = new float[chunkSize+1,chunkSize+1];
// fill heightMap
....
TerrainData terrainData = new TerrainData();
terrainData.size = new Vector3(chunkSize, highest_c, chunkSize);
// highest_c is the highest point in my terrain
terrainData.heightmapResolution = chunkSize + 1;
terrainData.SetHeights(0, 0, heightMap);
terrainData.baseMapResolution = chunkSize;
GameObject terrainObject = Terrain.CreateTerrainGameObject(terrainData);
terrainObject.transform.position = new Vector3(start_x, 0, start_z);
Terrain terrain = terrainObject.GetComponent<Terrain>();
terrain.basemapDistance = 100;
terrain.castShadows = true;
terrain.detailObjectDensity = 0.5f;
terrain.detailObjectDistance = 40;
terrain.heightmapMaximumLOD = 0;
Terrain.activeTerrain.heightmapPixelError = 10;
Terrain.activeTerrain.treeBillboardDistance = 100;
Terrain.activeTerrain.treeCrossFadeLength = 20;
Terrain.activeTerrain.treeDistance = 500;
Terrain.activeTerrain.treeMaximumFullLODCount = 200;
Does anyone know what's causing this?
EDIT: Adding another screenie to illustrate one of the issues. What's that 'foot' doing there?
Well, nobody told me the size of the map had to be 2^n. Feet-things problem is solved by increasing it to 128.
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Vector math problem 2 Answers
How do I deform a Marching Cube/Voxel Terrain? 1 Answer
spawning/instantiating based on a specific texture on terrain 1 Answer