Search Unity

Create a perfect downhill heightmap

Discussion in 'Editor & General Support' started by toum, Dec 6, 2009.

  1. toum

    toum

    Joined:
    Nov 21, 2009
    Posts:
    15
    Hi all i would like to design a perfect downhill height for a ski game.

    i edited a raw file into photoshop using white->black gradient. The slop is present into unity but there is lot of mini peaks along the downhill.

    There is a way to generate perfect heightmap using a code loop? If yes how?

    i use terrain of 2000 x 2000 x 1000


    Thanks,

    toum
     
  2. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    749
    I'm also interested in this.. its almost impossible to paint a smooth gradient ramp.
    Anyone got any tricks to achieve this ?
    special brush ? or filter ?

    I didnt try in photoshop... but make sure you have filtering/dithering off when making your gradient, that might be messing things up for you.
     
  3. Bongo

    Bongo

    Joined:
    Jul 24, 2009
    Posts:
    75
    From my experiences, heightmaps should be 16bit images. 8 bit images just dont have enough color information to make a smooth heightmap and can result in rather jagged terrain. That may be part of your problem.

    I also know taking an 8 bit image, converting it to 16 bit, and importing as a heightmap also makes lots of ugly data and creates a very lumpy terrain in unity because of the conversion.
     
  4. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,290
    I ran into the same problem.

    In Photoshop, using 16 bit and playing around with the overlay settings can improve your result. However, if you absolutely need a smooth slope, code is the only way.

    You could go into the Unity heightmap and run an algorithm over it ensuring that x+1 < x. I would strongly suggest then calling the brush instead of modifying the height directly, otherwise you just get one big canyon.

    The other alternative would be to include the slope generation in the heightfield generation. With the proper tools, you should be able to smooth that part out, maybe using the river generator of whatever you use to generate the heightmap.
     
  5. noamgat

    noamgat

    Joined:
    Nov 22, 2009
    Posts:
    125
    Found this (old) topic while looking to do the same, and what I eventually did was :

    Code (csharp):
    1.  
    2. [MenuItem("Terrain/Create Gradient Terrain")]
    3.     public static void CreateGradientTerrain()
    4.     {
    5.         if (Terrain.activeTerrain)
    6.         {
    7.             TerrainData td = Terrain.activeTerrain.terrainData;
    8.            
    9.             float[,] newSamples = new float[td.heightmapHeight, td.heightmapWidth];
    10.             for (int x = 0; x < td.heightmapWidth; x++)
    11.             {
    12.                 for (int y = 0; y < td.heightmapHeight; y++)
    13.                 {
    14.                     newSamples[y,x] = (float)x / td.heightmapWidth;
    15.                 }
    16.             }
    17.             td.SetHeights(0, 0, newSamples);
    18.            
    19.         }
    20.     }
    21.  
     
  6. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    749
    what it needs is a way that you can angle the brushes in 3d space in the editor, and as you move the brush around... at slides along the plane that you have angled it to..
    then you can easily make flat sloped surfaces.

    unity 3.1 ? heh
     
  7. oxl

    oxl

    Joined:
    Nov 21, 2008
    Posts:
    325
    Hi,

    L3DT by Bundysoft is a very nice Heightmap Editor that contains a ramp tool inside the 3D Preview / Editor.

    Using it in combination with the smooth tool might give you the result you are expecting.

    --
    oxl
     
  8. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    749
    thanks nice idea,
    but looks like that tool is for torque/no unity plugin?

    So I guess it would work, to build height maps first, then import into unity.

    But troublesome for rapid iteration and level editing within unity.

    Hopefully they will add this feature i na future release of unity.
     
  9. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
    Why can't you use one of the Road Tools with a really wide width?

    As a side note, it would be awesome if you could view terrain curvature. You could then see if there were any harsh differentials on your slope and smooth them out. They use this kind of thing in Rhino for boat hulls and vehicles to ensure air and waterflow around the bodies are smooth.