- Home /
Question by
MrVerdoux · Jul 09, 2013 at 05:25 PM ·
lightingshaderstransparency
Transparent + affected by light shader
Hi,
I´m new to unity shaders and I´m a little lost in a particular shader I´m trying to create. I want a shader that includes only one texture and keeps the transparent parts of that texture transparent, but I also want the non-transparent parts of the texture to be affected by light.
Is this possible?
Thank you.
Comment
Best Answer
Answer by MrVerdoux · Jan 13, 2014 at 04:28 PM
I finally got it!
Shader "Custom/SemiTransparent" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Alpha ("Alpha", Range(0,1)) = 0.5
}
SubShader {
Tags{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
}
Lighting On Cull Off ZWrite On
Blend SrcAlpha OneMinusSrcAlpha
LOD 200
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
float _Alpha;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = _Alpha;
}
ENDCG
}
FallBack "Diffuse"
}
Your answer
Follow this Question
Related Questions
TransparencyLM - Colored Shadows 0 Answers
Transparent Cutout Double Diffuse shader with accurate lighting? 0 Answers
How to make my shader have a variable transparency 1 Answer
Shader Constants - Lighting Params require Queue=Geometry? 1 Answer
Fading objects to transparent - Apply shader with a script? 2 Answers