Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

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:
    10
    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:
    423
    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:
    423
    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:
    423
    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:
    423
    You're welcome!