Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Terrain Terrain Toolbox feedback, partial tilesets not supported?

Discussion in 'World Building' started by wlad_s, Jul 12, 2019.

  1. wlad_s

    wlad_s

    Joined:
    Feb 18, 2011
    Posts:
    92
    Hello,

    Here's some TerrainToolbox feedback.

    I have tried importing my partial terrain tileset through terrain toolbox batch import and I'm getting errors. I presume that partial tilesets are not supported.

    Errors are either
    TerrainToolbox: Heightmap resolution per tile is not integer with current settings. You will get seams between tiles
    or
    TerrainToolbox: Heightmap resolution per tile is not square size with current settings.
    depending on the settings I've tried.

    Here is my tileset config.

    SM_Tiles_12x12_nocorners.jpg

    PS the reason I'm using partial tileset is because I don't need the terrain that is underwater so I haven't built it.

    PPS also, as you can see, my tileset doesn't start at 0,0. You might want to support that case as well, it would be a nice option to have.

    Thank you for your hard work WorldBuilding Team.
     
    Last edited: Jul 12, 2019
  2. wlad_s

    wlad_s

    Joined:
    Feb 18, 2011
    Posts:
    92
    On further inspection, even when I exported the missing dummy tiles, batch import didn't work.

    I got TerrainToolbox: Heightmap resolution per tile is not integer with current settings. You will get seams between tiles

    When I looked at the code, it seems that it always sets m_Settings.HeightmapWidth to the width of one heightmap in pixels, 4096 in my case. Then when it validates the files in ValidateHeightmap():

    float tileHeightX = (float)m_Settings.HeightmapWidth / (float)m_Settings.TilesX;
    float tileHeightX = 4096 / 12 = 341.33 which is not integer.

    HeightmapWidth for the whole terrain should be 49152 (4096*12)
     
  3. JHNO

    JHNO

    Joined:
    Nov 23, 2018
    Posts:
    1
    I also have this bug. When I tried to import 3x3 tiles heightmaps, Unity throwed an error. As you mentioned it is an issue with function:
    Code (CSharp):
    1.         bool ValidateHeightmap()
    2.         {        
    3.             if (!ToolboxHelper.IsPowerOfTwo(m_Settings.HeightmapWidth) || !ToolboxHelper.IsPowerOfTwo(m_Settings.HeightmapHeight))
    4.             {
    5.                 // texture is not power of two
    6.                 Debug.LogError("TerrainToolbox: Imported heightmap resolution is not power of two.");
    7.                 return false;
    8.             }
    9.  
    10.             if (m_Settings.TilesX != 0 && m_Settings.TilesZ != 0)
    11.             {
    12.                 float tileHeightX = (float)m_Settings.HeightmapWidth / (float)m_Settings.TilesX;
    13.                 float tileHeightZ = (float)m_Settings.HeightmapWidth / (float)m_Settings.TilesZ;
    14.                 if (tileHeightX != tileHeightZ)
    15.                 {
    16.                     // heights per tile is non-square
    17.                     Debug.LogError("TerrainToolbox: Heightmap resolution per tile is not square size with current settings.");
    18.                     return false;
    19.                 }
    20.                 if (!ToolboxHelper.IsInteger(tileHeightX) || !ToolboxHelper.IsInteger(tileHeightZ))
    21.                 {
    22.                     // heights per tile is not integer
    23.                     Debug.LogError("TerrainToolbox: Heightmap resolution per tile is not integer with current settings. You will get seams between tiles.");
    24.                     return false;
    25.                 }
    26.                 if (tileHeightX > 4096 || tileHeightX < 32)
    27.                 {
    28.                     // heightmap size per tile out of range
    29.                     Debug.LogError("TerrainToolbox: Heightmap resolution per tile is out of range. Supported resolution is from 32 to 4096.");
    30.                     return false;
    31.                 }
    32.             }        
    Also I do not understand why now heightmaps should have size 2^k, instead of 2^k+1.

    EDIT: When I commented out that if statement which check if tileHeightX is integer, my terrain was generated correctly. I think that this if statement should look like this:
    Code (CSharp):
    1.                 if (m_Settings.HeightmapMode == Heightmap.Mode.Global && (!ToolboxHelper.IsInteger(tileHeightX) || !ToolboxHelper.IsInteger(tileHeightZ)))
    2.                 {
    3.                     // heights per tile is not integer
    4.                     Debug.LogError("TerrainToolbox: Heightmap resolution per tile is not integer with current settings. You will get seams between tiles.");
    5.                     return false;
    6.                 }
     
    Last edited: Sep 6, 2019