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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
Shader "Brush/Particle/Snow" { Properties { _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5) _MainTex ("Particle Texture", 2D) = "white" {} _ScrollRate("Scroll Rate", Float) = 1.0 _ScrollDistance("Scroll Distance", Vector) = (1.0, 0, 0) _ScrollJitterIntensity("Scroll Jitter Intensity", Float) = 1.0 _ScrollJitterFrequency("Scroll Jitter Frequency", Float) = 1.0 _SpreadRate ("Spread Rate", Range(0.3, 5)) = 1.539 }
Category { Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "DisableBatching"="True" } Blend SrcAlpha One AlphaTest Greater .01 ColorMask RGB Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) }
SubShader { Pass {
CGPROGRAM #pragma vertex vert #pragma fragment frag #pragma multi_compile_particles #pragma multi_compile __ AUDIO_REACTIVE #pragma multi_compile __ TBT_LINEAR_TARGET #pragma target 3.0
#include "UnityCG.cginc" #include "../../../Shaders/Include/Brush.cginc" #include "../../../Shaders/Include/Particles.cginc"
sampler2D _MainTex; fixed4 _TintColor;
struct v2f { float4 vertex : SV_POSITION; fixed4 color : COLOR; float2 texcoord : TEXCOORD0; };
float4 _MainTex_ST; float _ScrollRate; float3 _ScrollDistance; float _ScrollJitterIntensity; float _ScrollJitterFrequency; float _SpreadRate;
v2f vert (ParticleVertexWithSpread_t v) { v2f o; v.color = TbVertToSrgb(v.color); float birthTime = v.texcoord.w; float rotation = v.texcoord.z; float halfSize = GetParticleHalfSize(v.corner.xyz, v.center, birthTime); float spreadProgress = SpreadProgress(birthTime, _SpreadRate); float4 center = SpreadParticle(v, spreadProgress); float4 center_WS = mul(unity_ObjectToWorld, center);
float scrollAmount = _Time.y; float t = fmod(scrollAmount * _ScrollRate + v.color.a, 1); float4 dispVec = (t - .5f) * float4(_ScrollDistance, 0.0); dispVec.x += sin(t * _ScrollJitterFrequency + _Time.y) * _ScrollJitterIntensity; dispVec.z += cos(t * _ScrollJitterFrequency * .5 + _Time.y) * _ScrollJitterIntensity; dispVec.xyz = spreadProgress * dispVec * kDecimetersToWorldUnits; center_WS += mul(xf_CS, dispVec);
float4 corner_WS = OrientParticle_WS(center_WS.xyz, halfSize, v.vid, rotation); #ifdef AUDIO_REACTIVE o.color = musicReactiveColor(v.color, _BeatOutput.w); corner_WS = musicReactiveAnimationWorldSpace(corner_WS, v.color, _BeatOutput.w, corner_WS.y*5); #else o.color = v.color; #endif
o.vertex = mul(UNITY_MATRIX_VP, corner_WS); o.color.a = pow(1 - abs(2*(t - .5)), 3); o.texcoord = TRANSFORM_TEX(v.texcoord.xy, _MainTex); return o; }
fixed4 frag (v2f i) : SV_Target { return SrgbToNative(2.0f * i.color * _TintColor * tex2D(_MainTex, i.texcoord)); } ENDCG } } } }
|