Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Terrain opacity as density problem and layers

Discussion in 'World Building' started by GineHeim, Jun 19, 2022.

  1. GineHeim

    GineHeim

    Joined:
    Nov 19, 2020
    Posts:
    3
    The "opacity as density" is set active on some of my texture layers, I have 4 texture layers currently and whenever I add a 5th texture layer the "opacity as density" stops working on all of the texture layers its enabled at?

    I'm currently using Urp 10 2020.3.18 LTS
     
  2. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    Hi. "Opacity as Density" will only work if you have 4 or less Terrain Layer assigned to your Terrain. Once you have more than that, it defaults to just blending solely based on the texture weights iirc.
     
  3. SgtLame

    SgtLame

    Joined:
    Nov 26, 2015
    Posts:
    129
    Hi,
    I need to set that "Opacity as density" property through C#, and I can't find the corresponding field or method in the TerrainData.terrainLayers field, nor in the TerrainLayer itself.
    Any ideas?
     
  4. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    Hello. If I remember correctly, you have to disable height-blending somewhere. Maybe on the HDRP/URP Terrain Material. Then you need to make sure there's a Mask Map assigned to the Terrain Layers. Then the `Density as Opacity` option should be there on the Terrain Layer.

    It might not be a property in C# on TerrainLayer but might be a Material Property that you can set if you have the right material instance
     
    Last edited: May 17, 2023
  5. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    Ok, looks like it's the .w component of TerrainLayer.diffuseRemapMin. So if TerrainLayer.diffuseRemapMin.w is 1 then Opacity as Density is enabled, and then disabled if it's 0.
     
    SgtLame likes this.
  6. SgtLame

    SgtLame

    Joined:
    Nov 26, 2015
    Posts:
    129
    Thank you wyattt_!
     
    wyattt_ likes this.
  7. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    You're welcome!