123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- Shader "YXJ/Particles/DistortionBase"
- {
- Properties
- {
- _TintColor("Tint Color",color) = (1,1,1,1)
- _MaskTex("Mask Tex (A)", 2D) = "white" {}
- _NoiseTex("Noise Texture (RG)", 2D) = "white" {}
- _HeatTime("Heat Time", range(0,1.5)) = 1
- _HeatForce("Heat Force", range(0,5)) = 0.1
- }
- SubShader
- {
- Tags{ "Queue" = "Transparent+100" "IgnoreProjector" = "True" "RenderType" = "Transparent" "LightMode" = "Grab_YXJ"}
- Cull Off Lighting Off ZWrite Off
- Pass
- {
- Blend SrcAlpha OneMinusSrcAlpha
- AlphaTest Greater .01
- HLSLPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #pragma fragmentoption ARB_precision_hint_fastest
- #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
- #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
- struct appdata_t
- {
- float4 vertex : POSITION;
- float4 color : COLOR;
- float2 texcoord: TEXCOORD0;
- };
- struct v2f
- {
- float4 vertex : POSITION;
- float4 color : COLOR;
- float2 uvMask : TEXCOORD0;
- float4 uvGrab : TEXCOORD1;
- };
- sampler2D _MaskTex; float4 _MaskTex_ST;
- sampler2D _NoiseTex; float4 _NoiseTex_ST;
- float4 _TintColor;
- half _HeatTime;
- half _HeatForce;
- SAMPLER(_CameraTransparentTexture);
- v2f vert (appdata_t v)
- {
- v2f o;
- VertexPositionInputs vertexInput = GetVertexPositionInputs(v.vertex.xyz);
- o.vertex = vertexInput.positionCS;
- o.color = v.color;
- o.uvMask = TRANSFORM_TEX(v.texcoord, _MaskTex);
- #if UNITY_UV_STARTS_AT_TOP
- float scale = -1.0;
- #else
- float scale = 1.0;
- #endif
- o.uvGrab.xy = (float2(o.vertex.x, o.vertex.y * scale) + o.vertex.w) * 0.5;
- o.uvGrab.zw = o.vertex.zw;
- return o;
- }
- half4 frag( v2f i ) : SV_Target
- {
- //noise effect
- half4 offsetColor1 = tex2D(_NoiseTex, i.uvMask + _Time.xz * _HeatTime);
- half4 offsetColor2 = tex2D(_NoiseTex, i.uvMask - _Time.yx * _HeatTime);
- half distortX = ((offsetColor1.r + offsetColor2.r) - 1) * _HeatForce;
- half distorty = ((offsetColor1.g + offsetColor2.g) - 1) * _HeatForce;
- half2 screenUV = (i.vertex.xy / _ScreenParams.xy)+ float2(distortX, distorty);
- half4 grab = tex2D(_CameraTransparentTexture, screenUV);
- half4 mask = tex2D(_MaskTex, i.uvMask);
- half maskA = min(mask.r, mask.a);
- return _TintColor * i.color * half4(grab.rgb, maskA);
- }
- ENDHLSL
- }
- }
- SubShader
- {
- Blend DstColor One
- Pass
- {
- Name "BASE"
- SetTexture[_MaskTex]
- {
- constantColor (0,0,0,0)
- combine texture * constant
- }
- }
- }
- }
|