Properties {
_EmissiveColor ("EmissiveColor", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_MySliderValue ("Slider Value", Range(0,10)) = 2.5
_TransVal("Transparency Value", Range(0,1)) = 0.5
}
SubShader {
Tags {
"RenderType"="TransparentCutout" "Queue"="AlphaTest"
}
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf BasicDiffuse alphatest:_TransVal addshadow fullforwardshadows // alpha:fade
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _MainTex;
float4 _EmissiveColor;
float4 _AmbientColor;
float _MySliderValue;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
// Albedo comes from a texture tinted by color
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) ;
c.rgb *= pow ((_EmissiveColor *3),_MySliderValue);
o.Albedo = c.rgb;
o.Alpha =c.a;
}
//half4 LightingName (SurfaceOutput s, half3 lightDir, half atten){}
//這個函數被用於forward rendering(正向渲染),但是不需要考慮view direction(觀察角度)時。
//half4 LightingName_PrePass (SurfaceOutput s, half4 light){}
//這個函數被用於需要使用defferred rendering(延遲渲染)時。
inline float4 LightingBasicDiffuse(SurfaceOutput s,fixed3 lightDir,half3 viewDir, fixed atten)
{
fixed3 h = normalize(lightDir + viewDir);
half difLight = max(0,dot(s.Normal,lightDir));
float nh = max(0,dot(s.Normal,h));
float spec = pow (nh,48.0);
half4 c ;
c.rgb = (s.Albedo * _LightColor0.rgb * difLight + _LightColor0.rgb* spec ) * (atten * 2);
c.a = s.Alpha;
return c;
}
ENDCG
}
FallBack "Diffuse"
}