Code : Tout sélectionner
Shader "Screen_Clamped_Emissive_Fade_Alpha" {
Properties {
_Color ( "Main Color", Color ) = ( 1, 1, 1, 1 )
_Blend ( "Blend", Range ( 0, 1 ) ) = 0.5
_MainTex ("Main Map", 2D) = "white" {}
_Texture2 ( "Texture 2", 2D ) = "white" {}
_AlphaTex ("Alpha mask (R)", 2D) = "white" {}
_EmissionPower ("Emission Power", Range(0,20)) = 1.0
}
SubShader {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
ZWrite Off
Lighting Off
Blend SrcAlpha OneMinusSrcAlpha
LOD 100
Pass
{
SetTexture[_MainTex]
SetTexture[_Texture2]
{
ConstantColor ( 0, 0, 0, [_Blend] )
Combine texture Lerp( constant ) previous
}
}
Cull Off
CGPROGRAM
#pragma surface surf NoLighting alpha noforwardadd
#include "UnityCG.cginc"
half4 LightingNoLighting (SurfaceOutput s, half3 lightDir, half atten) {
half4 c;
c.rgb = s.Albedo;
c.a = s.Alpha;
return c;
}
sampler2D _MainTex;
sampler2D _Texture2;
sampler2D _AlphaTex;
fixed4 _Color;
float _Blend;
float _EmissionPower;
struct Input {
float2 uv_MainTex;
float2 uv_Texture2;
float2 uv_AlphaTex;
};
void surf(Input IN, inout SurfaceOutput o) {
half4 tex = tex2D(_MainTex, IN.uv_MainTex) * _Color;
half4 c;
if (IN.uv_MainTex.x > 1.0 || IN.uv_MainTex.x < 0.0 || IN.uv_MainTex.y > 1.0 || IN.uv_MainTex.y < 0.0)
c = half4 (0, 0, 0, 0);
else
c = tex;
half4 tex2 = tex2D ( _Texture2, IN.uv_Texture2 ) * _Color;
o.Emission = lerp(c.rgb * _EmissionPower, tex2 * _EmissionPower, _Blend );
o.Albedo = fixed4 (0, 0, 0, 0);
o.Alpha = tex2D (_AlphaTex, IN.uv_AlphaTex).a;
}
ENDCG
}
Fallback "Unlit/Texture"
}