Search Unity

Normal map makes some artifact.

Discussion in 'Shaders' started by augustinus, Feb 21, 2017.

  1. augustinus

    augustinus

    Joined:
    Feb 3, 2015
    Posts:
    25
    When camera is near the object, there is no artifact.
    But, when camera is zoomed out from the object, normal makes some artifact like below images.

    aaa.png

    I checked every shader factor. (disabled and enabled). It's because normal map.
    And changing normal map setting have no effect.

    This is my normal map Setting.
    bbb.png


    My shader is a surface shader, just unpack normal and assign to normal variables.

    Code (CSharp):
    1. o.Normal = UnpackNormal(tex2D(_NormalMap, IN.uv_MainTex));

    Is there any way to remove the spots?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    I've not seen anything exactly like that before from just normal maps. However you probably shouldn't be using the 16 bits option for normals on organic objects, use compressed or 32 bits. 16 bits is the total per pixel, so only 4 bits per color channel because of how Unity stores normals on PC. That means the normals are only able to represent 16 directions on x and y!
     
  3. augustinus

    augustinus

    Joined:
    Feb 3, 2015
    Posts:
    25
    Okay, but TrueColor or Comperessed options doesn't make any changes.
     
  4. augustinus

    augustinus

    Joined:
    Feb 3, 2015
    Posts:
    25
    I found it.
    It's not normal map's problem.

    It's my code bug.

    Code (CSharp):
    1. fixed NdotV = dot(normal, viewDir);  <= this makes the artifact.
    2. fixed NdotL = dot(normal, lightDir) * 0.5 + 0.5;
    3. half3 ramp  = tex2D(_tex, half2(NdotL, NdotV)).rgb;
    4.  
    I changed the line.

    Code (CSharp):
    1. fixed NdotV = dot(normal, viewDir) * 0.5 + 0.5
    And It is solved.
    Thank you.