- Home /
Question by
DavidDebnar · Oct 12, 2014 at 03:55 PM ·
shaderalphablendingsurface shader
Luminance to Alpha
Hello! I've been fiddling around with surface shaders and trying to make luminance affect alpha, but it doesn't seem to be working properly. The Luminance (rgb) function, from what I can see, keeps returning a constant value for the entire object. Am I doing something very wrong, if so, what's the solution?
Shader "Luminance"
{
Properties
{
_Color ("Main Color", Color) = (1,1,1,1)
}
SubShader
{
Tags
{
"RenderType" = "Opaque"
"Queue" = "Transparent"
}
CGPROGRAM
#pragma surface surf Lambert alpha
float4 _Color;
struct Input
{
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o)
{
half4 c = _Color;
o.Albedo = c.rgb;
o.Alpha = Luminance (c.rgb) * c.a;
}
ENDCG
}
Fallback "Diffuse"
}
Comment
Your answer
Follow this Question
Related Questions
Alpha blending with more than one pass 0 Answers
Shader Doesn't Work On Android 1 Answer
Blending 3d planes with shader 0 Answers
Alpha Blending for projectors on transparent/cutout materials 0 Answers