Shader "Custom/fx_Dissolve_Mask_One"
{
Properties
{
_SliceGuide ("Slice Guide (RGB)", 2D) = "white" {}
_Clip("Clip", Range(0, 1)) = 0
[Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend("SrcBlend mode", Float) = 1
[Enum(UnityEngine.Rendering.BlendMode)] _DstBlend("DstBlend mode", Float) = 1
}
SubShader
{
// No culling or depth
Tags { "Queue"="Transparent" "RenderType"="Transparent" }
Cull Off ZWrite On //ZTest Always
Blend [_SrcBlend] [_DstBlend]
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
fixed4 color : COLOR;
float4 uv : TEXCOORD0;
float customdata1 : TEXCOORD1;
};
struct v2f
{
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 uv : TEXCOORD0;
float customdata1 : TEXCOORD1;
};
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.color = v.color;
o.uv = v.uv;
o.customdata1 = v.uv.z;
return o;
}
sampler2D _SliceGuide;
float _Clip;
fixed4 frag (v2f i) : SV_Target
{
// Custom Vertex Stream
float sliceAmount = 0;
sliceAmount = i.customdata1;
sliceAmount = min(sliceAmount, 1);
sliceAmount = max(sliceAmount, _Clip);
// Slice
fixed4 sliceColor = tex2D(_SliceGuide, i.uv);
sliceColor.rgb -= sliceAmount;
clip(sliceColor);
// Main Texture
fixed3 mainColor = sliceColor;
mainColor = i.color;
// Final
fixed4 final = fixed4(0,0,0,0);
final.rgb = mainColor.rgb;
final.a = i.color.a;
return final;
}
ENDCG
}
}
}
Shader "Custom/fx_Dissolve_Mask_Twe"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_SliceGuide ("Slice Guide (RGB)", 2D) = "white" {}
_BurnSize ("Burn Size", Range(0.0, 1.0)) = 0.15
_Clip("Clip", Range(0, 1)) = 0
[Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend("SrcBlend mode", Float) = 1
[Enum(UnityEngine.Rendering.BlendMode)] _DstBlend("DstBlend mode", Float) = 1
}
SubShader
{
Tags { "Queue"="Transparent" "RenderType"="Transparent" }
Cull Off ZWrite On// ZTest Always
Blend [_SrcBlend] [_DstBlend]
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
fixed4 color : COLOR;
float4 uv : TEXCOORD0;
float customdata1 : TEXCOORD1;
};
struct v2f
{
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 uv : TEXCOORD0;
float customdata1 : TEXCOORD1;
};
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.color = v.color;
o.uv = v.uv;
o.customdata1 = v.uv.z;
return o;
}
sampler2D _MainTex;
sampler2D _SliceGuide;
float _BurnSize;
float _Clip;
fixed4 frag (v2f i) : SV_Target
{
// Custom Vertex Stream
float sliceAmount = 0;
sliceAmount = i.customdata1;
sliceAmount = min(sliceAmount, 1);
sliceAmount = max(sliceAmount, _Clip);
// Slice
fixed4 sliceColor = tex2D(_SliceGuide, i.uv);
sliceColor.rgb -= sliceAmount;
clip(sliceColor);
// Main Texture
fixed3 mainColor = tex2D (_MainTex, i.uv).rgb;
mainColor *= i.color;
// Burn
half test = tex2D (_SliceGuide, i.uv).rgb - sliceAmount;
if(test < _BurnSize && sliceAmount > 0 && sliceAmount < 1)
{
// 외각
mainColor = tex2D(_MainTex, float2(test *(1/_BurnSize), 0));
}
// Final
fixed4 final = fixed4(0,0,0,0);
final.rgb = mainColor.rgb;
final.a = i.color.a;
return final;
}
ENDCG
}
}
}