Files
kaiju/Assets/Scenes/MDNA_Silicon/Silicon.shader
T

94 lines
3.0 KiB
Plaintext

Shader "FullScreen/Silicon"
{
Properties
{
_SpectrumTexture("SpectrumTexture", 2D) = "white" {}
_ThemeTexture("ThemeTexture", 2D) = "white" {}
_SpectrumSize("SpectrumSize", float) = 16
_SphereSize("SphereSize", range(0, 3)) = 1
_SphereStretch("SphereStretch", range(0, 3)) = 1
}
HLSLINCLUDE
// HDRP stuff
#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"
// here we go...
sampler2D _SpectrumTexture;
sampler2D _ThemeTexture;
float _SpectrumSize;
float4 FullScreenPass(Varyings varyings) : SV_Target {
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);
float2 ndc = posInput.positionNDC;
float4 color = float4(0.0, 0.0, 0.0, 0.0);
// convert to glsl mode and fix aspect ratio
float2 uv = posInput.positionNDC - 0.5;
uv.x *= _ScreenParams.x / _ScreenParams.y;
float time = _Time.y;
// Background
float4 outColour = float4(0.8+0.2*uv.y,0.8+0.2*uv.y,0.8+0.2*uv.y,1);
// [unroll(100)]
for(int i=0; i<40; i++) {
// bubble seeds
float pha = sin(float(i)*546.13+1.0)*0.5 + 0.5;
float siz = pow( sin(float(i)*651.74+5.0)*0.5 + 0.5, 4.0 );
float pox = sin(float(i)*321.55+4.1) * 1 / 1;
// buble size, position and color
float band = 1 / ((i % _SpectrumSize) + 1);
float freq = tex2D(_SpectrumTexture, band);
float rad = 0.1 + 0.1*freq;
float2 pos = float2( pox, -1.0-rad + (2.0+2.0*rad)*fmod(pha+0.1*time*(0.2+0.8*siz),1.0));
float dis = length( uv - pos );
float3 col = lerp( float3(0.94,0.3,0.0), float3(0.1,0.4,0.8), 0.5+0.5*sin(float(i)*1.2+1.9));
col+= 8.0*smoothstep( rad*0.95, rad, dis );
// render
float f = length(uv-pos)/rad;
f = sqrt(clamp(1.0-f*f,0.0,1.0));
outColour -= float4(col.zyx *(1.0-smoothstep( rad*0.95, rad, dis )) * f, 0.0);
}
// Vignetting
// outColour *= sqrt(1.5-0.5*length(uv));
return outColour;
}
ENDHLSL
SubShader
{
Tags{ "RenderPipeline" = "HDRenderPipeline" }
Pass
{
Name "GeneDrive"
ZWrite Off
ZTest Always
// Blend SrcAlpha OneMinusSrcAlpha
Cull Off
HLSLPROGRAM
#pragma fragment FullScreenPass
ENDHLSL
}
}
Fallback Off
}