Search Unity

Resolved Splat maps artifacts between layers

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

  1. NanushTol

    NanushTol

    Joined:
    Jan 9, 2018
    Posts:
    131
    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:
    131
    That was quicker then I thought :)
    needed to set: sRGB = false;
    Now it works properly
     
    Gravesend likes this.