- Home /
 
               Question by 
               cowtrix · Jan 03, 2014 at 03:47 AM · 
                shadershadersalphasurfaceshader  
              
 
              Multiply Shader with Alpha
So I have a shader that successfully overlays a texture (i.e. sets the alpha to the grayscale). However, I want to multiply that final alpha by a given float parameter so it isn't completely opaque when the input is, and that's where things seem to fall apart.
Here's the shader:
 Shader "Custom/Multiply" {
     Properties {
         _MainTex ("Base (RGB)", 2D) = "white" {}
         _Alpha ("Alpha", Float) = 0.5
     }
     SubShader {
         Tags { "RenderType"="Opaque" }
         LOD 200
         
         CGPROGRAM
         #pragma surface surf Lambert alpha
 
         sampler2D _MainTex;
         uniform half4 _Alpha;
         
         struct Input {
             half Alpha;
             float2 uv_MainTex;
         };
 
         void surf (Input IN, inout SurfaceOutput o) {
             half4 c = tex2D (_MainTex, IN.uv_MainTex);
             half4 a = _Alpha;
             o.Albedo = c.rgb;
             o.Alpha =  (1.0f-c.r) * _Alpha;
         }
         ENDCG
     } 
     FallBack "Diffuse"
 }
When I change that final "_Alpha" to something like "0.5f" it works fine. What am I doing wrong passing this parameter in to the shader?
               Comment
              
 
               
              To anyone wondering, changing the declaration of _Alpha from uniform half4 _Alpha to uniform half _Alpha fixed the issue. 
Your answer
 
 
             Follow this Question
Related Questions
Unlit Shader with alpha mask 2 Answers
Shader with zwrite, shadows and alpha (special alpha) 2 Answers
shader problem 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                