// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
|
|
|
// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
|
|
|
|
Shader "Unlit/DissolveEffect2"
|
|
{
|
|
Properties
|
|
{
|
|
_MainTex("Base (RGB)", 2D) = "white" {}
|
|
//_ParentAlpha("_ParentAlpha", Float) = 15
|
|
_ParentDist("_ParentDist", Float) = 0
|
|
_ParentPos("ParentPos", Vector) = (0,0,0,0)
|
|
_PlaneDir("PlaneDir", Vector) = (1,-0.6,0,0)
|
|
|
|
}
|
|
SubShader
|
|
{
|
|
//Tags
|
|
//{
|
|
//"Queue" = "Transparent"
|
|
//"RenderType" = "Transparent"
|
|
//}
|
|
Pass
|
|
{
|
|
//Blend SrcAlpha OneMinusSrcAlpha
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#include "UnityCG.cginc"
|
|
|
|
sampler2D _MainTex;
|
|
float4 _MainTex_ST;
|
|
uniform half _ParentDist;
|
|
//uniform half _ParentAlpha;
|
|
uniform half4 _ParentPos;
|
|
uniform half4 _PlaneDir;
|
|
|
|
|
|
struct v2f {
|
|
half4 vertex : POSITION;
|
|
float2 uv : TEXCOORD0;
|
|
float3 posWorld : TEXCOORD1;
|
|
};
|
|
|
|
v2f vert(appdata_base v) {
|
|
v2f o;
|
|
o.posWorld = mul(unity_ObjectToWorld, v.vertex).xyz;
|
|
o.vertex = UnityObjectToClipPos(v.vertex);
|
|
o.uv = v.texcoord;
|
|
return o;
|
|
}
|
|
|
|
|
|
fixed4 frag(v2f v) : COLOR
|
|
{
|
|
_ParentPos.x = -_ParentDist;
|
|
half3 viewDirection = normalize(v.posWorld.xyz - _ParentPos.xyz);
|
|
half angle = dot(_PlaneDir, viewDirection);
|
|
_ParentPos.x = +_ParentDist;
|
|
viewDirection = normalize(v.posWorld.xyz - _ParentPos.xyz);
|
|
half angle2 = dot(_PlaneDir, viewDirection);
|
|
half2 di = half2(_ParentDist/13, 0);
|
|
if (angle2 < 0)
|
|
{
|
|
di.x = -_ParentDist/13;
|
|
}
|
|
if (angle > 0 && angle2 < 0)
|
|
{
|
|
clip(-1);
|
|
}
|
|
else
|
|
{
|
|
clip(1);
|
|
}
|
|
|
|
float2 uv = v.uv - di;
|
|
fixed4 col = tex2D(_MainTex,TRANSFORM_TEX(uv,_MainTex));
|
|
//fixed4 col = tex2D(_MainTex, v.uv);
|
|
//col.a = 1 - _ParentDist / _ParentAlpha;
|
|
return col;
|
|
}
|
|
ENDCG
|
|
}
|
|
}
|
|
//FallBack "Diffuse"
|
|
}
|