Search Unity

lines between textures/planes in tiled terrain

Discussion in 'World Building' started by cbodapati, Apr 5, 2019.

  1. cbodapati

    cbodapati

    Joined:
    Oct 13, 2008
    Posts:
    13
    Hello everyone,

    I'm trying to build a terrain with map tiles. I wrote a shader which can take 10 textures and apply to the mesh (like attached image 3 )which can take like 10 materials and tried to place these planes next to each other.

    Problem - I can see some lines like in the attachment 1 and 2
    lines like in 1 are caused by each row in the mesh & adjacent planes
    lines like in 2 are caused by 2 textures of the same material

    This happened with with both unity mesh and a blender exported mesh.

    I read here that if I use CLAMP in the wrapmode, I can get rid of these lines.
    I tried with quads with CLAMP, and the lines are no more there....but I cannot apply the height map for the terrain in this approach.

    Is there something I can do to get rid of the lines and apply the height map is my question.

    Thanks in advance
    Srikanth
     

    Attached Files:

    • 1.jpg
      1.jpg
      File size:
      22.4 KB
      Views:
      591
    • 2.jpg
      2.jpg
      File size:
      29.8 KB
      Views:
      582
    • 3.jpg
      3.jpg
      File size:
      60.1 KB
      Views:
      580
    yuximchuk99 likes this.
  2. Destriarch

    Destriarch

    Joined:
    Feb 18, 2020
    Posts:
    6
    Yeah, this one's been driving me crazy. I know it's an old question, but I had several problems that were causing issues like this for me and it took me ages to sort them all out.

    I think there's a slight strangeness in the way Unity samples texture colours, in that if you try and draw a sample from exactly x:0 or y:0, it will interpolate between the target pixel and the colour white. I don't know if that's really the case or why, but it would explain the results I was seeing. This happens even with the texture set to clamp and point filtering (I'm doing a faux-8-bit-style game).

    To get around the issue, instead of using the exact UV coordinates from the input structure, I did this:

    Code (CSharp):
    1. float x1 = max(0.000001f, IN.uv_MainTex.x);
    2. float y1 = max(0.000001f, IN.uv_MainTex.y);
    3. tex2D(_MainTex, float2(x1, y1));
    This fixed the issue for me, but it really shouldn't happen in the first place.
     
    yuximchuk99 likes this.