Files
HX_MapEditor/Assets/Effect/JDJ/Effect_DistortionAdd.shader
2025-06-14 13:46:24 +08:00

86 lines
1.9 KiB
Plaintext

// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "JDJ/Distort_additive" {
Properties {
_TintColor ("颜色", Color) = (0.5,0.5,0.5,0.5)
_NoiseTex ("颜色贴图 (RG)", 2D) = "white" {}
_MainTex ("半透明 (A)", 2D) = "white" {}
_HeatTime ("速度",Float) = 0.5
_ForceX ("U动画", Float) = 0.4
_ForceY ("V动画", Float) = 0.4
}
Category {
Tags { "Queue"="Transparent" "RenderType"="Transparent" }
Blend SrcAlpha One
Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) }
BindChannels {
Bind "Color", color
Bind "Vertex", vertex
Bind "TexCoord", texcoord
}
SubShader {
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#pragma multi_compile_particles
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
fixed4 color : COLOR;
float2 texcoord: TEXCOORD0;
};
struct v2f {
float4 vertex : POSITION;
fixed4 color : COLOR;
float2 uvmain : TEXCOORD1;
};
fixed4 _TintColor;
fixed _ForceX;
fixed _ForceY;
fixed _HeatTime;
float4 _MainTex_ST;
float4 _NoiseTex_ST;
sampler2D _NoiseTex;
sampler2D _MainTex;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.color = v.color;
o.uvmain = TRANSFORM_TEX( v.texcoord, _MainTex );
return o;
}
fixed4 frag( v2f i ) : COLOR
{
//noise effect
fixed4 offsetColor1 = tex2D(_NoiseTex, i.uvmain + _Time.xz*_HeatTime);
fixed4 offsetColor2 = tex2D(_NoiseTex, i.uvmain + _Time.yx*_HeatTime);
i.uvmain.x += ((offsetColor1.r + offsetColor2.r) - 1) * _ForceX;
i.uvmain.y += ((offsetColor1.r + offsetColor2.r) - 1) * _ForceY;
return 2.0f * i.color * _TintColor * tex2D( _MainTex, i.uvmain);
}
ENDCG
}
}
// ------------------------------------------------------------------
// Fallback for older cards and Unity non-Pro
SubShader {
Blend DstColor Zero
Pass {
Name "BASE"
SetTexture [_MainTex] { combine texture }
}
}
}
}