Layer stacking

This commit is contained in:
2026-05-02 18:18:49 +10:00
parent fb1bf01fef
commit 80399c5a15
18 changed files with 3761 additions and 799 deletions

View File

@@ -67,6 +67,33 @@
"min": 0.0,
"max": 0.5,
"step": 0.01
},
{
"id": "bloomAmount",
"label": "Bloom",
"type": "float",
"default": 0.18,
"min": 0.0,
"max": 0.6,
"step": 0.01
},
{
"id": "fadeAmount",
"label": "Fade",
"type": "float",
"default": 0.22,
"min": 0.0,
"max": 0.75,
"step": 0.01
},
{
"id": "noiseAmount",
"label": "Noise",
"type": "float",
"default": 0.055,
"min": 0.0,
"max": 0.2,
"step": 0.005
}
]
}

View File

@@ -39,6 +39,38 @@ float3 yiq2rgb(float3 c)
);
}
float noiseHash(float2 p)
{
return frac(sin(dot(p, float2(127.1, 311.7))) * 43758.5453123);
}
float3 chromaSpeckle(float2 uv, float framecount)
{
float2 coarseUv = floor(uv);
float r = noiseHash(coarseUv + float2(framecount * 19.0, framecount * 11.0));
float g = noiseHash(coarseUv + float2(framecount * 23.0 + 17.0, framecount * 7.0 + 31.0));
float b = noiseHash(coarseUv + float2(framecount * 13.0 + 47.0, framecount * 29.0 + 9.0));
return float3(r, g, b) - 0.5;
}
float3 softBloom(float2 uv, float2 outputResolution, float radius)
{
float2 pixel = 1.0 / max(outputResolution, float2(1.0, 1.0));
float2 dx = float2(pixel.x * radius, 0.0);
float2 dy = float2(0.0, pixel.y * radius);
float3 sum = sampleVideo(frac(uv)).rgb * 0.28;
sum += sampleVideo(frac(uv + dx)).rgb * 0.14;
sum += sampleVideo(frac(uv - dx)).rgb * 0.14;
sum += sampleVideo(frac(uv + dy)).rgb * 0.14;
sum += sampleVideo(frac(uv - dy)).rgb * 0.14;
sum += sampleVideo(frac(uv + dx + dy)).rgb * 0.075;
sum += sampleVideo(frac(uv + dx - dy)).rgb * 0.075;
sum += sampleVideo(frac(uv - dx + dy)).rgb * 0.075;
sum += sampleVideo(frac(uv - dx - dy)).rgb * 0.075;
return sum;
}
float3 blurVhs(float2 uv, float d, int sampleCount)
{
float3 sum = float3(0.0, 0.0, 0.0);
@@ -107,6 +139,26 @@ float4 shadeVideo(ShaderContext context)
float halationMask = smoothstep(0.45, 1.0, halationLuma) * halationAmount;
color += halationSource * float3(1.0, 0.38, 0.24) * halationMask * 0.35;
float3 bloomSource = softBloom(context.uv, context.outputResolution, 2.0 + smear * 2.5);
float bloomLuma = dot(bloomSource, float3(0.299, 0.587, 0.114));
float bloomMask = smoothstep(0.32, 1.0, bloomLuma) * bloomAmount;
color = lerp(color, bloomSource, bloomAmount * 0.18);
color += bloomSource * float3(1.0, 0.96, 0.92) * bloomMask * 0.24;
float2 noiseUv = context.uv * context.outputResolution * float2(0.55, 1.1);
float3 speckle = chromaSpeckle(noiseUv, framecount);
float luma = dot(color, float3(0.299, 0.587, 0.114));
float noiseMask = lerp(0.65, 1.0, 1.0 - saturate(luma));
float3 chromaNoise = float3(speckle.x * 1.1, speckle.y * 0.45, speckle.z * 1.2);
color += chromaNoise * noiseAmount * noiseMask;
color.rg = lerp(color.rg, float2(color.r, color.g) + speckle.xy * noiseAmount * 0.18, 0.35);
color.b = lerp(color.b, color.b + speckle.z * noiseAmount * 0.22, 0.45);
float3 grayscale = float3(luma, luma, luma);
color = lerp(color, grayscale, fadeAmount * 0.18);
color = color * (1.0 - fadeAmount * 0.08) + float3(0.055, 0.055, 0.065) * fadeAmount;
color = lerp(color, softBloom(context.uv, context.outputResolution, 1.0 + smear), fadeAmount * 0.12);
float vignetteBase = context.uv.x * (1.0 - context.uv.x) * context.uv.y * (1.0 - context.uv.y);
float vignette = saturate(pow(vignetteBase * 16.0, 0.22));
color *= lerp(1.0 - vignetteAmount, 1.0, vignette);