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

why one minus vertex color (zero value) is zero?

Discussion in 'Shaders' started by bbsuuo, Nov 2, 2021.

  1. bbsuuo

    bbsuuo

    Joined:
    Jul 21, 2016
    Posts:
    16
    • hi ,I'm writing a UI shader and simulate photoshop effect
    the code like (IN.color is vertex color) :

    fixed4 frag(v2f IN) : SV_Target
    {
    float4 testColor = tex2D(_MainTex, IN.texcoord) * IN.color;
    return (1 - testColor.a);
    }

    and This seems to be working well , but when i set vertex color zero , i get zero output , why ??
     
  2. bbsuuo

    bbsuuo

    Joined:
    Jul 21, 2016
    Posts:
    16
    ok , I get the idea the image will ignore when color alpha zero object rendering, i use frame debugger confirmed, so this is an optimization