Search Unity

Terrain, Tile, UV, Splat

Discussion in 'Editor & General Support' started by stylemert, Mar 20, 2018.

  1. stylemert

    stylemert

    Joined:
    Feb 24, 2018
    Posts:
    2
    Hi Unity Family!
    I have 1028x1028 mapdata
    -Heightmap (size 257x257)
    -Alphamap (size 257x257)
    -Per tile have 2 Texture (128x128, DXT), 2 UV (need blend)

    My problem is texture resolution and uv. How can i rotate tile with using uv and fix tile resolution ? I can fix this with plane * mapsize^2, but render time is too long. I want to use terrain object.



    // SplatPrototypes
    SplatPrototype[] tex = new SplatPrototype[tileRes.Length];
    for (int i = 0; i < tileRes.Length; i++)
    {
    tex[i] = new SplatPrototype();
    tex[i].texture = tileRes[i];
    tex[i].tileSize = new Vector2(128,128);
    }
    t.terrainData.splatPrototypes = tex;

    // HeightMap
    float[,] heightmap = t.terrainData.GetHeights(0, 0, mapData.mapSize, mapData.mapSize);
    for (var y = 0; y < t.terrainData.heightmapHeight; y++)
    for (var x = 0; x < t.terrainData.heightmapWidth; x++)
    heightmap[y, x] = mapData.mData[x][y].Height/1.5f;
    t.terrainData.SetHeights(0, 0,heightmap);

    // AlphaMaps
    float[,,] map = new float[t.terrainData.alphamapWidth, t.terrainData.alphamapHeight, tileRes.Length];
    for (var y = 0; y < t.terrainData.alphamapHeight; y++)
    {
    for (var x = 0; x < t.terrainData.alphamapWidth; x++)
    {
    for (int i = 0; i < tileRes.Length; i++)
    map[y, x, i] = 0f;

    if (mapData.mData[x][y].Tex1Idx <= tileRes.Length - 1) map[y, x, mapData.mData[x][y].Tex1Idx] = 0.5f;
    if (mapData.mData[x][y].Tex2Idx <= tileRes.Length - 1) map[y, x, mapData.mData[x][y].Tex2Idx] = 0.5f;
    }
    }
    t.terrainData.SetAlphamaps(0, 0, map);




     
    Last edited: Mar 20, 2018
  2. stylemert

    stylemert

    Joined:
    Feb 24, 2018
    Posts:
    2
    My other project, its good but render time too long.
     
  3. repahidis

    repahidis

    Joined:
    Feb 15, 2017
    Posts:
    1
    I have same issue pls help.