Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Terrain: lowering past zero?

Discussion in 'Editor & General Support' started by Marscaleb, Sep 30, 2020.

  1. Marscaleb

    Marscaleb

    Joined:
    Jan 7, 2014
    Posts:
    1,036
    I'm getting started with learning how to use terrains in Unity.

    One thing I notice right away is that the terrain height starts at zero, and I can't paint anything lower than that.

    But what if I want to?

    What if I create my large and beautiful terrain, but then find I have section that needs to be lower than zero? How can I paint beneath that? How can I make a valley that goes lower than that default height?

    I tried googling the answer, but it just took me to answer from older versions of Unity that are no longer relevant.
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,893
    Set the whole terrain to be flat at height X. You can now make valleys of up to depth X. That's how minecraft does it.
     
  3. Marscaleb

    Marscaleb

    Joined:
    Jan 7, 2014
    Posts:
    1,036
    If I were starting a map, perhaps, but what if I already have something built and I need it to go lower?
    What if I underestimated how deep I want my terrain to go?
     
  4. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,893
    Not sure. Can you use one of the tools to uniformly add N height to the entire existing terrain? Maybe add height tool with extremely large size and 100% opacity?
     
  5. BillytheGamer

    BillytheGamer

    Joined:
    Oct 1, 2020
    Posts:
    1
    Set the position Y to the negative the height of the Terrain and everything should line up again.
     
  6. Marscaleb

    Marscaleb

    Joined:
    Jan 7, 2014
    Posts:
    1,036
    You mean for the terrain's game object? Well yeah, that would need to be done too. But how could I add an even and exact amount to my entire terrain to begin with? I'm asking about how to not have to repaint an entire terrain just because I started at a zero value that was too high.
     
  7. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,893
    I would try the following, in this order:

    1. Save your project and create a backup (or just commit if you're using Version Control)
    2. Use the Raise or Lower Terrain tool. Create a custom brush for it that is just a white square. Set the Opacity to 100 and the brush size to as high as you can. Then click/Shift click on your terrain until you're happy with the height. I haven't tested this but.. I think with an all-white brush it should uniformly raise/lower the entire terrain. Just be careful you don't go too high or low as you can erase your existing peaks/troughs
    3. Worst case scenario, you can export the heightmap and edit it directly using either an editor script, or photoshop/GIMP. If you uniformly lighten the map that should have the effect of raising all of the terrain. Then you can reimport the heightmap.
     
    almeidabernardu and adamgolden like this.
  8. wjt6

    wjt6

    Joined:
    Aug 10, 2020
    Posts:
    12
    Just adding to this since I ran into the same issue. I'm using multiple terrains and needed to uniformly raise all of them in order to decrease my sea floor. The largest brush wouldn't cover all my terrains at once, so to make sure I did it neat and evenly across all terrains I deactivated them all, then activated them one-by-one and used Stamp Terrain, set a stamp height of 100 (or whatever value you want to raise your terrain by) and for Max<--->Add I chose add. The huge brush rasied each terrain by 100 units so they all matched up at a new height. Then I was able to scoop out a deeper ocean floor
     
    swimswim and Deanford like this.
  9. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,520
    You can also just update the TerrainData with a quick script. My grenade-damager does it at runtime (does not save the result), but you can do it at editor time and persist the result.



    Look for the
    TerrainPreAdjustment.cs
    script.

    https://github.com/kurtdekker/makeg...nStuff/TerrainDamager/TerrainPreAdjustment.cs

    In the above line 67 makes the terrain data copy. Don't make that copy and you'll just be changing the actual terrain data. BE SURE TO USE SOURCE CONTROL IN CASE SOMETHING GOES WRONG!!!

    Full project at:

    MakeGeo is presently hosted at these locations:

    https://bitbucket.org/kurtdekker/makegeo

    https://github.com/kurtdekker/makegeo

    https://gitlab.com/kurtdekker/makegeo

    https://sourceforge.net/p/makegeo
     
    swimswim and maewionn like this.