Shader "Unlit/SolarFlare" { Properties { _Speed("Flow Speed", Range(0.01, 5.0)) = 1.0 _Scale("Pattern Scale", Range(0.5, 20.0)) = 3.0 _FlareColor("Flare Color", Color) = (1.0, 0.3, 0.05, 1.0) _HotColor("Hot Color", Color) = (1.0, 0.8, 0.3, 1.0) _Intensity("Intensity", Range(0.1, 10.0)) = 3.0 _FlowDir("Flow Direction", Range(-1, 1)) = 1.0 _FadeEdge("Edge Fade Power", Range(0.5, 5.0)) = 2.0 _FadeEnds("End Fade", Range(0.0, 0.5)) = 0.15 _Wisps("Wisp Count", Range(1.0, 8.0)) = 4.0 } SubShader { Tags { "RenderType"="Transparent" "Queue"="Transparent" } LOD 100 Blend One One ZWrite Off Cull Off Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct appdata { float4 vertex : POSITION; float2 uv : TEXCOORD0; }; struct v2f { float2 uv : TEXCOORD0; float4 vertex : SV_POSITION; }; float _Speed; float _Scale; float4 _FlareColor; float4 _HotColor; float _Intensity; float _FlowDir; float _FadeEdge; float _FadeEnds; float _Wisps; // 3D simplex noise (same as LiquidStar) float3 mod289(float3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } float4 mod289(float4 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } float4 permute(float4 x) { return mod289(((x * 34.0) + 10.0) * x); } float4 taylorInvSqrt(float4 r) { return 1.79284291400159 - 0.85373472095314 * r; } float snoise(float3 v) { const float2 C = float2(1.0 / 6.0, 1.0 / 3.0); const float4 D = float4(0.0, 0.5, 1.0, 2.0); float3 i = floor(v + dot(v, C.yyy)); float3 x0 = v - i + dot(i, C.xxx); float3 g = step(x0.yzx, x0.xyz); float3 l = 1.0 - g; float3 i1 = min(g.xyz, l.zxy); float3 i2 = max(g.xyz, l.zxy); float3 x1 = x0 - i1 + C.xxx; float3 x2 = x0 - i2 + C.yyy; float3 x3 = x0 - D.yyy; i = mod289(i); float4 p = permute(permute(permute( i.z + float4(0.0, i1.z, i2.z, 1.0)) + i.y + float4(0.0, i1.y, i2.y, 1.0)) + i.x + float4(0.0, i1.x, i2.x, 1.0)); float n_ = 0.142857142857; float3 ns = n_ * D.wyz - D.xzx; float4 j = p - 49.0 * floor(p * ns.z * ns.z); float4 x_ = floor(j * ns.z); float4 y_ = floor(j - 7.0 * x_); float4 x = x_ * ns.x + ns.yyyy; float4 y = y_ * ns.x + ns.yyyy; float4 h = 1.0 - abs(x) - abs(y); float4 b0 = float4(x.xy, y.xy); float4 b1 = float4(x.zw, y.zw); float4 s0 = floor(b0) * 2.0 + 1.0; float4 s1 = floor(b1) * 2.0 + 1.0; float4 sh = -step(h, float4(0, 0, 0, 0)); float4 a0 = b0.xzyw + s0.xzyw * sh.xxyy; float4 a1 = b1.xzyw + s1.xzyw * sh.zzww; float3 p0 = float3(a0.xy, h.x); float3 p1 = float3(a0.zw, h.y); float3 p2 = float3(a1.xy, h.z); float3 p3 = float3(a1.zw, h.w); float4 norm = taylorInvSqrt(float4(dot(p0,p0), dot(p1,p1), dot(p2,p2), dot(p3,p3))); p0 *= norm.x; p1 *= norm.y; p2 *= norm.z; p3 *= norm.w; float4 m = max(0.6 - float4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0); m = m * m; return 42.0 * dot(m * m, float4(dot(p0,x0), dot(p1,x1), dot(p2,x2), dot(p3,x3))); } v2f vert(appdata v) { v2f o; o.vertex = UnityObjectToClipPos(v.vertex); o.uv = v.uv; return o; } float4 frag(v2f i) : SV_Target { float time = _Time.y * _Speed; // UV: x wraps around cylinder, y goes along length float2 uv = i.uv; // Flow along the cylinder length float flow = uv.y + time * _FlowDir * 0.2; // Wispy tendrils flowing along the cylinder float3 p = float3(uv.x * _Scale, flow * _Scale, time * 0.1); float n1 = snoise(p); // 1 float n2 = snoise(p * 1.7 + float3(5.2, time * 0.15, 1.3)); // 2 float n3 = snoise(p * 0.5 + float3(time * 0.1, 3.1, 7.4)); // 3 // Wisp pattern - creates streaky tendrils float wispAngle = uv.x * _Wisps * 6.2831; float wisp = sin(wispAngle + n1 * 3.0 + flow * 4.0) * 0.5 + 0.5; wisp = pow(wisp, 3.0); // Combine noise layers float pattern = wisp * (n2 * 0.5 + 0.5); pattern += pow(max(0, n3 * 0.5 + 0.5), 2.0) * 0.3; // Pulsing hotspots that travel along the cylinder float pulse = snoise(float3(uv.x * 2.0, flow * 2.0, time * 0.3)); // 4 float hotspot = pow(saturate(pulse), 4.0); // Radial fade - fade out at edges of cylinder (using X as wrap-around) float radialDist = abs(uv.x - 0.5) * 2.0; float radialFade = pow(1.0 - saturate(radialDist), _FadeEdge); // End caps fade - fade near top and bottom of cylinder float endFade = smoothstep(0.0, _FadeEnds, uv.y) * smoothstep(1.0, 1.0 - _FadeEnds, uv.y); // Color float3 col = lerp(_FlareColor.rgb, _HotColor.rgb, hotspot + pattern * 0.3); col *= _Intensity; float alpha = pattern * radialFade * endFade + hotspot * radialFade * endFade * 2.0; alpha = saturate(alpha); return float4(col * alpha, 1.0); } ENDCG } } }