Change transparency of a shader

Hi,

I would like to change the whole transpancy over time of a billboard that I am creating via a shader. I am using this shader I found in order to render billboard, but I don’t know how I can add a property to change the whole transparency of the billboard, keeping the alpha of the png cutout.

Any help would be appreciated :slight_smile:

Shader "Cg  shader for billboards" {
   Properties {
      _MainTex ("Texture Image", 2D) = "white" {}
      _CutOff("Cut off", float) = 0.1
      _Alpha("Alpha", float) = 0.1
   }
   SubShader {
      Pass {   
         CGPROGRAM
 
         #pragma vertex vert  
         #pragma fragment frag 
 
         // User-specified uniforms            
         uniform sampler2D _MainTex;        
         uniform float _CutOff;
 
         struct vertexInput {
            float4 vertex : POSITION;
            float4 tex : TEXCOORD0;
         };
         struct vertexOutput {
            float4 pos : SV_POSITION;
            float4 tex : TEXCOORD0;
         };
 
         vertexOutput vert(vertexInput input) 
         {
            vertexOutput output;
 
            output.pos = mul(UNITY_MATRIX_P, 
              mul(UNITY_MATRIX_MV, float4(0.0, 0.0, 0.0, 1.0))
              - float4(input.vertex.x, input.vertex.z, 0.0, 0.0));
 
            output.tex = input.tex;
 
            return output;
         }
 
         float4 frag(vertexOutput input) : COLOR
         {
 
            float4 color = tex2D(_MainTex, float2(input.tex.xy));   
           // 
            if(color.a < _CutOff) discard;
            return color;
         }
 
         ENDCG
      }
   }
}

Ok, I figured it out :slight_smile:

Shader "Cg  shader for billboards" {
   Properties {
      _Alpha ("Alpha", Range(0,1)) = 0.3
      _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {}
      _CutOff("Cut off", Range(0,1)) = 0.1
   }
   SubShader {
      Tags { "Queue"="Transparent" "RenderType"="Transparent" }
      Blend SrcAlpha OneMinusSrcAlpha
      AlphaTest Greater 0.1
      Pass {   
         CGPROGRAM 

         #pragma vertex vert  
         #pragma fragment frag 
 
         // User-specified uniforms            
         uniform sampler2D _MainTex;
         uniform float _CutOff;
         uniform float _Alpha;   
 
         struct vertexInput {
            float4 vertex : POSITION;
            float4 tex : TEXCOORD0;
         };
         struct vertexOutput {
            float4 pos : SV_POSITION;
            float4 tex : TEXCOORD0;
         };
 
         vertexOutput vert(vertexInput input) 
         {
            vertexOutput output;
 
            output.pos = mul(UNITY_MATRIX_P, 
              mul(UNITY_MATRIX_MV, float4(0.0, 0.0, 0.0, 1.0))
              - float4(input.vertex.x, input.vertex.z, 0.0, 0.0));
 
            output.tex = input.tex;
 
            return output;
         }
 
         float4 frag(vertexOutput input) : COLOR
         {
 
            float4 color = tex2D(_MainTex, float2(input.tex.xy));   
           //
           if(color.a < _CutOff) discard;
           else color.a = _Alpha;
           
           // color = Color(color.r, color.g, color.b, 0.2);
           // if(color.a < _CutOff) discard;
           // else (color = Color(color.r, color.g, color.b, 0.2)
            return color;
         }
 
         ENDCG
      }
   }
}