- Home /
Transparent/Specular Shader - I want alpha to control spec, not transparency
Hi there,
Like the title says. I'm trying to use the transparent/specular shader because it's necessary if I want spec and the ability to fade an object when the camera can't see the character. The alpha for transparency should be flat white, but the alpha for specular needs to be the alpha channel I've made.
It's using the alpha channel I've made for the transparency instead and giving zero control over the specular.
How do I remedy this?
Answer by ScroodgeM · Jul 14, 2012 at 09:15 AM
just insert in shader code (marked):
original shader: texture's alpha affects to glossy and transparency, color's alpha affects to transparency only
o.Gloss = tex.a; o.Alpha = tex.a * _Color.a;
texture's alpha affects to glossy and not transparency, color's alpha affects to transparency only
o.Gloss = tex.a; o.Alpha = _Color.a;
color's alpha affects to glossy and not transparency, texture's alpha affects to transparency only
o.Gloss = _Color.a; o.Alpha = tex.a;
shader code below
Shader "Transparent/Specular 2" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 0) _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 _MainTex ("Base (RGB) TransGloss (A)", 2D) = "white" {} }
SubShader { Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} LOD 300
CGPROGRAM #pragma surface surf BlinnPhong alpha
sampler2D _MainTex; fixed4 _Color; half _Shininess;
struct Input { float2 uv_MainTex; };
void surf (Input IN, inout SurfaceOutput o) { fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); o.Albedo = tex.rgb * _Color.rgb; ----------------->>> insert lines here o.Specular = _Shininess; } ENDCG }
Fallback "Transparent/Specular" }