Shader "Kaiju/Bubbles" { Properties { _SpectrumTexture("SpectrumTexture", 2D) = "white" {} _ThemeTexture("ThemeTexture", 2D) = "white" {} _SpectrumSize("SpectrumSize", float) = 16 } HLSLINCLUDE #pragma vertex Vert #pragma target 4.5 #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassCommon.hlsl" // The PositionInputs struct allow you to retrieve a lot of useful information for your fullScreenShader: // struct PositionInputs // { // float3 positionWS; // World space position (could be camera-relative) // float2 positionNDC; // Normalized screen coordinates within the viewport : [0, 1) (with the half-pixel offset) // uint2 positionSS; // Screen space pixel coordinates : [0, NumPixels) // uint2 tileCoord; // Screen tile coordinates : [0, NumTiles) // float deviceDepth; // Depth from the depth buffer : [0, 1] (typically reversed) // float linearDepth; // View space Z coordinate : [Near, Far] // }; // To sample custom buffers, you have access to these functions: // But be careful, on most platforms you can't sample to the bound color buffer. It means that you // can't use the SampleCustomColor when the pass color buffer is set to custom (and same for camera the buffer). // float4 SampleCustomColor(float2 uv); // float4 LoadCustomColor(uint2 pixelCoords); // float LoadCustomDepth(uint2 pixelCoords); // float SampleCustomDepth(float2 uv); // There are also a lot of utility function you can use inside Common.hlsl and Color.hlsl, // you can check them out in the source code of the core SRP package. sampler2D _SpectrumTexture; sampler2D _ThemeTexture; float3 pulsar(in float3 p, in float2 uv, float4 spectrum) { float accum = 0.2; float prev = 0; float tw = 1.0; float str = lerp(24.0, 26.0, spectrum.x); for (int i = 0; i < 18; ++i) { float mag = dot(p, p); // p = abs(p) / mag + float3(-.5, -.42 - cos(_Time.y*0.2)*0.02, -1.75 + sin(_Time.y*0.2)*0.003); float gangsta = -0.41; float tripp = -1.75; float yee = 0.004; float yuh = 0.02; // float gangsta = lerp(-0.42, -0.42, spectrum.z); // float yee = lerp(0.005, 0.006, spectrum.y); // float yuh = lerp(0.1, 0.1, spectrum.x); p = abs(p) / mag + float3(-.5, gangsta - cos(_Time.y*0.2)* yuh, tripp + sin(_Time.y*0.2)* yee); float w = exp(-float(i) / str); accum += w * exp(-str * pow(abs(mag - prev), 2.2)); tw += w; prev = mag; } float t = clamp(5.0 * accum / tw - 0.9, 0.0, 1.0); return float3(1.3*t*t*t*(1.0 - length(uv)*0.2) , 1.2*t*t, 1.0*t); } const float PHI = 1.61803398874989484820459; // Φ = Golden Ratio float gold_noise(in float2 xy, in float seed) { return frac(tan(distance(xy*PHI, xy)*seed)*xy.x); } float4 FullScreenPass(Varyings varyings) : SV_Target { UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(varyings); float depth = LoadCameraDepth(varyings.positionCS.xy); PositionInputs posInput = GetPositionInput(varyings.positionCS.xy, _ScreenSize.zw, depth, UNITY_MATRIX_I_VP, UNITY_MATRIX_V); float3 viewDirection = GetWorldSpaceNormalizeViewDir(posInput.positionWS); float4 color = float4(0.0, 0.0, 0.0, 0.0); // Load the camera color buffer at the mip 0 if we're not at the before rendering injection point if (_CustomPassInjectionPoint != CUSTOMPASSINJECTIONPOINT_BEFORE_RENDERING) color = float4(CustomPassLoadCameraColor(varyings.positionCS.xy, 0), 1); // get uv float2 uv = posInput.positionNDC - 0.5; // fix aspect ratio // uv.x *= _ScreenParams.x / _ScreenParams.y; float4 output = float4(0.0, 0.0, 0.0, 0.0); float3 p = float3(uv * (_ScreenParams.xy / _ScreenParams.x) / 0.2, 0.0); float seed = 1239959818; // cool modulation float time = _Time.y; float sub = tex2D(_SpectrumTexture, 0.0); float bass = tex2D(_SpectrumTexture, 0.25); float mids = tex2D(_SpectrumTexture, 0.50); float highs = tex2D(_SpectrumTexture, 0.75); float4 spectrum = float4(sub, bass, mids, highs) * 2; float dir = ceil(sin(_Time.y)); // output = float4( // pulsar(p * lerp(0.97, 0.99, spectrum.y), uv, spectrum).r, // pulsar(p * lerp(0.97, 0.99, spectrum.y), uv, spectrum).gb, // 1.0 // ); output = float4( pulsar(p, uv, spectrum), 1.0 ); return output; } ENDHLSL SubShader { Tags{ "RenderPipeline" = "HDRenderPipeline" } Pass { Name "Custom Pass 0" ZWrite Off ZTest Always Blend SrcAlpha OneMinusSrcAlpha Cull Off HLSLPROGRAM #pragma fragment FullScreenPass ENDHLSL } } Fallback Off }