Search Unity

Shader artifacts

Discussion in 'Shaders' started by jRocket, Apr 26, 2017.

  1. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    700
    I'm getting some weird shader artifacts that appear at certain angles in my custom surface shader. It looks like they are appearing in certain triangles on my mesh. Fearing some precision issue, I changed my half's to floats, and disabled mesh compression on my mesh- but to no avail. I found the part of my code that seems to be causing it though-

    Code (CSharp):
    1. float mask = saturate(pow(1 - IN.color.a, _Power));
    2. o.Albedo =  mask;
    Any idea why this would be happening?
     

    Attached Files:

  2. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    700
    Okay, I figured out that I have to saturate my inverted vertex alpha first.

    Code (CSharp):
    1. pow(saturate(1 - IN.color.a), _Power);
    I'm not sure why that works, but it works...