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

Resolved Splat maps artifacts between layers

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

  1. NanushTol


    Jan 9, 2018
    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;
    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. = mapData.splat0;
    3.         terrainData.CopyActiveRenderTextureToTexture(TerrainData.AlphamapTextureName, 0, splatRect, new Vector2Int(0, 0), false);
  2. NanushTol


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