Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    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.

Resolved Splat maps artifacts between layers

Discussion in 'World Building' started by NanushTol, Apr 29, 2023.

  1. NanushTol

    NanushTol

    Joined:
    Jan 9, 2018
    Posts:
    138
    I'm generating a terrain procedurally and trying to set the splay maps,
    I'm doing so in a shader that takes in 2 textures 1 for each layer, then I make sure their sum is equal to 1.
    then I'm copying the texture into the splat map texture using CopyActiveRenderTextureToTexture.

    The problem is that I get a lighter color in the fade between the layers as shown in the image.
    Any suggestions on how to correct this?

    the render texture format is "ARGB32"
    there is nothing fancy in the code, just a simple texture copy and source over backdrop blending.
    here is the shader code

    Code (CSharp):
    1. fixed4 frag(v2f i) : SV_Target
    2.             {
    3.                 float b = tex2D(_MainTex, i.uv).r;
    4.                 float s = tex2D(_TexB, i.uv).r;
    5.  
    6.                 return float4(b * (1-s), s, 0, 0);
    7.             }
    here is the C# code that copies the texture
    Code (CSharp):
    1. RectInt splatRect = new RectInt(0, 0, terrainData.alphamapResolution, terrainData.alphamapResolution);
    2.         RenderTexture.active = mapData.splat0;
    3.         terrainData.CopyActiveRenderTextureToTexture(TerrainData.AlphamapTextureName, 0, splatRect, new Vector2Int(0, 0), false);
    upload_2023-4-29_23-0-13.png
     
  2. NanushTol

    NanushTol

    Joined:
    Jan 9, 2018
    Posts:
    138
    That was quicker then I thought :)
    needed to set: sRGB = false;
    Now it works properly
     
    Gravesend likes this.