1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
| Shader "GameUI/Particles/Transparent Particle Add 1" { Properties { _InitColor("InitColor", Color) = (1,1,1,1) _MainTex ("Base (RGB), Alpha (A)", 2D) = "black" {} _AlphaTex ("Alpha Texture",2D) = "red" {} }
SubShader { LOD 100
Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" "RenderPipeline" = "UniversalPipeline" } Pass { Cull Off Lighting Off ZWrite Off Offset -1, -1 Fog { Mode Off } ColorMask RGB Blend One One
CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc"
sampler2D _MainTex; float4 _MainTex_ST; sampler2D _AlphaTex; float4 _ClipRange0 = float4(0.0, 0.0, 1.0, 1.0); float2 _ClipArgs0 = float2(1000.0, 1000.0); half4 _InitColor;
float4x4 _UIWorldtoUIRoot;
struct appdata_t { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; };
struct v2f { float4 vertex : POSITION; half4 color : COLOR; float2 texcoord : TEXCOORD0; float2 worldPos : TEXCOORD1; };
v2f o;
v2f vert (appdata_t v) { o.vertex = UnityObjectToClipPos(v.vertex); float4 worldPos = mul(unity_ObjectToWorld, v.vertex); worldPos = mul(_UIWorldtoUIRoot, worldPos); o.color = v.color; o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex); o.worldPos = worldPos.xy * _ClipRange0.zw + _ClipRange0.xy; return o; }
half4 frag (v2f IN) : COLOR { // Softness factor float2 factor = (float2(1.0, 1.0) - abs(IN.worldPos)) * _ClipArgs0; log2(factor); // Sample the texture //half4 col = GreyUI(_MainTex,_AlphaTex,IN.texcoord,IN.color); half4 col = tex2D(_MainTex, IN.texcoord) * IN.color; col.a = tex2D(_AlphaTex, IN.texcoord).r * IN.color.a; col.a *= clamp( min(factor.x, factor.y), 0.0, 1.0); col *= _InitColor; col.rgb *= col.a;
return col; } ENDCG } } }
|