Shader "Effect/Edge_Dissolve"
|
{
|
Properties
|
{
|
_MainTex ("Diffuse", 2D) = "white" { }
|
_Noise ("Noise", 2D) = "white" { }
|
_edge ("勾边大小", Float) = 0.1
|
_brightness ("勾边亮度", Float) = 100
|
_diffuseStrength ("diffuse强度", Float) = 10
|
_color ("color", Color) = (0.8, 0.3, 0.1, 1)
|
}
|
|
SubShader
|
{
|
Tags { "IgnoreProjector" = "True" "Queue" = "Transparent" "RenderType" = "Transparent" }
|
|
Pass
|
{
|
Tags { "LightMode" = "ForwardBase" }
|
|
Blend SrcAlpha OneMinusSrcAlpha
|
Cull Off
|
ZWrite Off
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
#pragma fragment frag
|
//#define UNITY_PASS_FORWARDBASE
|
#include "UnityCG.cginc"
|
#pragma multi_compile_fwdbase
|
#pragma exclude_renderers xbox360 ps3 flash
|
#pragma target 3.0
|
|
uniform sampler2D _MainTex;
|
uniform sampler2D _Noise;
|
uniform float _edge;
|
uniform float _brightness;
|
uniform float _diffuseStrength;
|
uniform float4 _color;
|
|
struct VertexInput
|
{
|
float4 vertex: POSITION;
|
float3 normal: NORMAL;
|
float4 tangent: TANGENT;
|
float2 texcoord0: TEXCOORD0;
|
float4 vertexColor: COLOR;
|
};
|
|
struct VertexOutput
|
{
|
float4 pos: SV_POSITION;
|
float2 uv0: TEXCOORD0;
|
float4 vertexColor: COLOR;
|
};
|
|
VertexOutput vert(VertexInput v)
|
{
|
VertexOutput o = (VertexOutput)0;
|
o.uv0 = v.texcoord0;
|
o.vertexColor = v.vertexColor;
|
o.pos = UnityObjectToClipPos(v.vertex);
|
|
return o;
|
}
|
|
fixed4 frag(VertexOutput i): COLOR
|
{
|
|
fixed4 _DiffuseColor = tex2D(_MainTex, i.uv0);
|
fixed4 _NoiseColor = tex2D(_Noise, i.uv0);
|
fixed3 finalColor = (_diffuseStrength * (_color.rgb * _DiffuseColor.rgb)) * _DiffuseColor.r;
|
|
fixed edgeA = step(_NoiseColor.r, (_edge + i.vertexColor.r));
|
fixed edgeB = step(_NoiseColor.r, i.vertexColor.r);
|
|
return fixed4(finalColor * (1 + (i.vertexColor.a * _DiffuseColor.a * (edgeA - edgeB) * _brightness)), i.vertexColor.a * _DiffuseColor.a);
|
}
|
ENDCG
|
|
}
|
}
|
// FallBack "Additive"
|
}
|