Spine溶解效果试做
2023/11
21
14:11
Shader "Spine/Skeleton-Dissolve" {
Properties{
_Cutoff("Alpha cutoff", Range(0,1)) = 0.0
_Color("Color", Color) = (1.000000,1.000000,1.000000,1.000000)
_Alpha("Alpha ",Range(0,1)) = 1
_LumV("LumV",Range(0,1)) = 0
_TintBlackV("TintBlackV",Range(0,1)) = 0
_TintWhiteV("TintWhiteV", Range(0,1)) = 0
[NoScaleOffset] _MainTex ("Main Texture", 2D) = "black" {}
[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 1
[HideInInspector] _StencilRef("Stencil Reference", Float) = 1.0
[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Comparison", Float) = 8 // Set to Always as default
// Outline properties are drawn via custom editor.
[HideInInspector] _OutlineWidth("Outline Width", Range(0,8)) = 3.0
[HideInInspector] _OutlineColor("Outline Color", Color) = (1,1,0,1)
[HideInInspector] _OutlineReferenceTexWidth("Reference Texture Width", Int) = 1024
[HideInInspector] _ThresholdEnd("Outline Threshold", Range(0,1)) = 0.25
[HideInInspector] _OutlineSmoothness("Outline Smoothness", Range(0,1)) = 1.0
[HideInInspector][MaterialToggle(_USE8NEIGHBOURHOOD_ON)] _Use8Neighbourhood("Sample 8 Neighbours", Float) = 1
[HideInInspector] _OutlineMipLevel("Outline Mip Level", Range(0,3)) = 0
_DissolveTexture("溶解纹理", 2D) = "black" {}
_DissolveSize("纹理缩放", Float) = 10
_DissolveSpeed("溶解速度", Float) = 10
_DissolveColor("溶解颜色", Color) = (1.000000,1.000000,1.000000,1.000000)
_DissolveEdge("溶解边缘宽度", Float) = 3
}
SubShader {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
Fog { Mode Off }
Cull Off
ZWrite Off
Lighting Off
Blend One OneMinusSrcAlpha
Stencil {
Ref[_StencilRef]
Comp[_StencilComp]
Pass Keep
}
Pass {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
Name "Normal"
ColorMask RGBA
CGPROGRAM
#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
sampler2D _DissolveTexture;
fixed _Cutoff;
int _GreyScale;
float4 _Color;
half _Alpha;
float _LumV;
float _TintBlackV;
float _TintWhiteV;
float _DissolveSpeed;
float _DissolveSize;
float _DissolveEdge;
float4 _DissolveColor;
struct VertexInput {
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
float4 vertexColor : COLOR;
};
struct VertexOutput {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
float4 uv2 : TEXCOORD1;
float4 vertexColor : COLOR;
};
VertexOutput vert (VertexInput v) {
VertexOutput o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv2 = ComputeScreenPos(o.pos);
o.uv = v.uv;
o.vertexColor = v.vertexColor;
return o;
}
float4 frag (VertexOutput i) : SV_Target {
float4 texColor = tex2D(_MainTex, i.uv);
texColor.a = lerp(0, texColor.a, _Alpha);
#if defined(_STRAIGHT_ALPHA_INPUT)
texColor.rgb *= texColor.a;
#endif
float2 disUv = i.uv2.xy / _DissolveSize;
float4 disCol = tex2D(_DissolveTexture, disUv);
float ds = _DissolveSpeed / 10;
float alpha = clamp( (_Time.y % ds) / ds, 0, 1);
clip(disCol.r - alpha );
float a = step( disCol.r - alpha, _DissolveEdge / 100);
texColor.rgb = lerp(texColor.rgb, texColor.rgb * _DissolveColor.rgb, a);
return texColor;
}
ENDCG
}
}
CustomEditor "SpineShaderWithOutlineGUI"
}
CopyRights: The Post by BY-NC-SA For Authorization,Original If Not Noted,Reprint Please Indicate From 老刘@开发笔记
Post Link: Spine溶解效果试做
Post Link: Spine溶解效果试做