Search Unity

line artifacts between uv on using fmod

Discussion in 'Shaders' started by HP, Apr 6, 2013.

  1. HP

    HP

    Joined:
    Nov 20, 2012
    Posts:
    80
    I have a little problem with a shader I wrote.
    There are line artifacts between the uv tiling of the texture.
    Is there something I'm doing wrong or does uv's are not between 0.0 and 1.0?
    I have no idea what could be causing this.

    Here is a screenshot of the problem:
    $shader_problem_fmod_texture_uv.jpg

    and this is the Texture:
    $shader_problem_fmod_texture_uv2.jpg

    Here is the code:
    Code (csharp):
    1.  
    2. Shader "custom/Test Shader"
    3. {
    4.     Properties
    5.     {
    6.         _MainTex ("Base (RGB)", 2D) = "white" {}
    7.     }
    8.     SubShader
    9.     {
    10.         Tags { "RenderType"="Opaque" }
    11.        
    12.         CGPROGRAM
    13.         #pragma surface surf Lambert
    14.  
    15.         sampler2D _MainTex;
    16.  
    17.         struct Input
    18.         {
    19.             float2 uv_MainTex;
    20.         };
    21.        
    22.         void surf (Input IN, inout SurfaceOutput o)
    23.         {
    24.             float2 pgUvMainTex1 = float2(fmod(IN.uv_MainTex.x,0.5), fmod(IN.uv_MainTex.y,0.5)+0.5);
    25.             half4 color1 = tex2D (_MainTex, pgUvMainTex1);
    26.  
    27.             o.Albedo = color1.rgb;
    28.             o.Alpha = 1;
    29.         }
    30.         ENDCG
    31.     }
    32.     FallBack "Diffuse"
    33. }
    34.  
    35.  
     
  2. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
  3. HP

    HP

    Joined:
    Nov 20, 2012
    Posts:
    80
    Thanks for the reply. Now I know what the problem is. (mipmap) :)

    Hmm, is there another way to get atlas texture working on my shader?
    I need it for my terrain for detail textures etc.

    Or is it possible to extend the editor (inspector) for terrain painting with more textures on one splat (like diffuse, normal, detail, ...)?