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.
  2. Dismiss Notice

Is there a workarround for using terrain map mask in built-in renderer?

Discussion in 'General Graphics' started by Wolderado2, Apr 8, 2020.

  1. Wolderado2

    Wolderado2

    Joined:
    Jul 25, 2016
    Posts:
    9
    I am trying out the substance designer and everything is fine. Except I want to use height maps and ambient occlusion textures in terrain. Terrain layer material has a texture slot called Map mask but after asking to unity, I learned that map masks are not supported in built-renderer. I lose half of the details because of it. Is there a workaround to use these textures?

    (Map mask = Detail mask)


    Terrain.png HowItSupposedToLookLike.png ForBetterComparison.png
     
    Last edited: Apr 8, 2020
  2. Arycama

    Arycama

    Joined:
    May 25, 2014
    Posts:
    182
    You need to write a custom terrain shader, or switch to HDRP which supports this natively.

    It's actually pretty easy to modify the built-in terrain shader to accept mask maps, they are provided to the shader as _Mask0, _Mask1, _Mask2, _Mask3.

    The builtin terrain shader supports Smoothness in the alpha channel of the Albedo texture.

    Then you just need to apply parallax (Assuming that's what you want the height for), and to output the values to the Surface-Shader channels for Occlusion and Metallic.

    However this does get expensive quite quickly, especially for a terrain with more than 4 textures. (Because you're sampling 3 textures, for four channels, which is 12 texture lookups per pass) There's some more clever terrain shaders and techniques out there for handling this kind of thing in a more performant manner if it becomes an issue.
     
  3. Wolderado2

    Wolderado2

    Joined:
    Jul 25, 2016
    Posts:
    9
    Thanks! This is exactly what I need. I didn't know you can assign materials to the terrain. I don't think performance is going to be an issue since our game has fogs so I can just blank out the texture far away. It wouldn't hurt looking some performance techniques though.
     
  4. Kritankboy

    Kritankboy

    Joined:
    Aug 8, 2020
    Posts:
    14
    I am like not experienced with shaders, would you provide the modified shader here if you can? That would be a big help sir
     
  5. Wolderado2

    Wolderado2

    Joined:
    Jul 25, 2016
    Posts:
    9
    Sorry I've since lost that project files. I can't remember if I wrote a shader for it but I know not long after this post I switched to a plugin called Micro-splat terrain. It supports height maps and more. It generates terrain materials automatically based on some parameters.

    https://assetstore.unity.com/packages/tools/terrain/microsplat-96478

    It has its own issues but generally it works very well. Developer is very responsive too.

    You can alternatively bake occlusion texture on to the albedo texture
     
    Kritankboy likes this.
  6. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,751
    I wonder how this could be done in Amplify shader, or does it only work as hard coded?