80 lines
2.1 KiB
Plaintext
80 lines
2.1 KiB
Plaintext
Shader "Zhanyou/Particles/RimColor" {
|
|
Properties {
|
|
_TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
|
|
_InnerColor ("Inner Color", Color) = (0.5,0.5,0.5,0.5)
|
|
_InnerColorPower ("Inner Color Power", Range(0.0,1.0)) = 0.5
|
|
_RimPower ("Rim Power", Range(0.0,5.0)) = 2.5
|
|
_AlphaPower ("Alpha Rim Power", Range(0.0,8.0)) = 4.0
|
|
_AllPower ("All Power", Range(0.0, 10.0)) = 1.0
|
|
}
|
|
|
|
Category {
|
|
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
|
|
Blend SrcAlpha OneMinusSrcAlpha
|
|
ColorMask RGB
|
|
//Cull Off
|
|
Lighting Off
|
|
ZWrite Off
|
|
|
|
SubShader {
|
|
Pass {
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#pragma target 2.0
|
|
#pragma multi_compile_particles
|
|
#pragma multi_compile_fog
|
|
|
|
#include "UnityCG.cginc"
|
|
|
|
fixed4 _TintColor;
|
|
fixed4 _InnerColor;
|
|
half _InnerColorPower;
|
|
half _RimPower;
|
|
half _AlphaPower;
|
|
half _AllPower;
|
|
|
|
struct appdata_t {
|
|
float4 vertex : POSITION;
|
|
float3 normal : NORMAL;
|
|
fixed4 color : COLOR;
|
|
};
|
|
|
|
struct v2f {
|
|
float4 vertex : SV_POSITION;
|
|
fixed4 color : COLOR;
|
|
half3 worldNormal : TEXCOORD0;
|
|
float3 worldPos : TEXCOORD1;
|
|
UNITY_FOG_COORDS(2)
|
|
};
|
|
|
|
float4 _MainTex_ST;
|
|
|
|
v2f vert (appdata_t v)
|
|
{
|
|
v2f o;
|
|
o.vertex = UnityObjectToClipPos(v.vertex);
|
|
o.color = v.color;
|
|
o.worldNormal = UnityObjectToWorldNormal(v.normal);//normalize(unity_WorldToObject[0].xyz * v.normal.x + unity_WorldToObject[1].xyz * v.normal.y + unity_WorldToObject[2].xyz * v.normal.z);
|
|
o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
|
|
UNITY_TRANSFER_FOG(o,o.vertex);
|
|
return o;
|
|
}
|
|
|
|
fixed4 frag (v2f i) : SV_Target
|
|
{
|
|
half3 worldNormal = i.worldNormal;
|
|
half3 viewDir = normalize(UnityWorldSpaceViewDir(i.worldPos));
|
|
half rim = 1.0 - saturate(dot (viewDir, worldNormal));
|
|
fixed4 col = _TintColor * i.color;
|
|
col.rgb = col.rgb * pow(rim, _RimPower) * _AllPower + _InnerColor.rgb * 2 * _InnerColorPower;
|
|
col.a *= pow (rim, _AlphaPower) * _AllPower;
|
|
UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(0,0,0,0)); // fog towards black due to our blend mode
|
|
return col;
|
|
}
|
|
ENDCG
|
|
}
|
|
}
|
|
}
|
|
}
|