Why is my transparency black? (Surface shader, Dissolve Mask)

Hello,
I started learning about shaders today mostly because i needed something specific and i didn’t have another programmer around to hassle. After a morning of reading books I have concocted the following shader.

What it does is:

  • Grab textures packed into the RGB channels and i ignore the diffuse

  • Combine those and apply a “Tint”

  • Apply “Exclusion” color blending to the main texture

  • Map on some scrolling texture that is visible in area;s from the MainTexture.a

  • Round off the shader with a dissolve effect

What it doesn’t do: My dissolve effect is black :frowning:
Which i’m guessing has to with with either a) I manage my alpha’s incorrectly, b) wrong BLEND keywords or c) i forgot stupidly to set the texture’s to have an alpha channel.

Please have a look!

Shader "Custom/Filip" {
    Properties {
        _Tint ("Tint", Color) = (1,1,1,1)
        _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {}
        _ScrollingTex( "Scrolling Map", 2D ) = "white"{}
        _ScrollSpeed( "Scroll Speed", float ) = 10
        _DissolveMask( "Dissolve Mask", 2D ) = "white" {}
        _DissolveVal("Dissolve Value", Range(-0.2, 1.2)) = 1.2
        _LineWidth("Line Width", Range(0.0, 0.2)) = 0.1
        _LineColor("Line Color", Color) = (1.0, 1.0, 1.0, 1.0)
    }
    SubShader {
        Tags{ "Queue" = "Transparent" "RenderType" = "Transparent"}
        Blend SrcAlpha OneMinusSrcAlpha 
        CGPROGRAM
        #pragma surface surf NoLighting

        sampler2D _MainTex;
        sampler2D _ScrollingTex;
        sampler2D _DissolveMask;
       
        float4 _LineColor;
        float _DissolveVal;
        float _LineWidth;
        fixed4 _Tint;
        float _ScrollSpeed;

        struct Input
        {
            float2 uv_MainTex;
            float2 uv_ScrollingTex;
            half2 uv_DissolveMask;
        };

       
        float4 Multiply (float4 cBase, float4 cBlend)
        {
            return (cBase * cBlend);
        }
       
        float4 Screen (float4 cBase, float4 cBlend)
        {
            return (1 - (1 - cBase) * (1 - cBlend));
        }
       
        float4 Overlay (float4 cBase, float4 cBlend)
        {
            float4 cNew;
            cNew = step(0.5,cBase);
            cNew= lerp((cBase*cBlend*2),(1.0-(2.0*(1.0-cBase)*(1.0-cBlend))),cNew);
            cNew.a = 1.0;
           
            return cNew;
        }
       
        float4 Exclusion (float4 cBase, float4 cBlend)
        {
            return (.5 - 2 * (cBase - .5) * (cBlend - .5));
        }

        fixed4 LightingNoLighting(SurfaceOutput s, fixed3 lightDir, fixed atten)
        {
            return (fixed4(0,0,0,0));
        }

        void surf (Input IN, inout SurfaceOutput o)
        {
            fixed2 scrolledUV = IN.uv_ScrollingTex;
            fixed xScrollValue = _ScrollSpeed * _Time;
            scrolledUV += fixed2( xScrollValue, 0 );
           
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
            fixed4 scroll = tex2D (_ScrollingTex, scrolledUV);
            half4 dissolve = tex2D(_DissolveMask, IN.uv_DissolveMask);
            half4 clear = half4(0.0);
           
            int isClear = int(dissolve.r - (_DissolveVal + _LineWidth) + 0.99);
            int isAtLeastLine = int(dissolve.r - (_DissolveVal) + 0.99);
            half4 altCol = lerp(_LineColor, clear, isClear);
           
            fixed4 r = c.r;
            fixed4 g = c.g;
            fixed4 b = c.b;
           
            float4 final = r + g + b;
            final = Exclusion( final, _Tint );
            final = lerp( final, scroll, c.a );
            final = lerp( final, altCol, isAtLeastLine);
           
            o.Albedo = final;
            o.Emission = final;
            o.Alpha = lerp(1.0, 0.0, isClear);
        }
       
       
        ENDCG
    }
    FallBack "Diffuse"
}

Bump

Bump