38 lines
1.1 KiB
Plaintext
38 lines
1.1 KiB
Plaintext
float ringMask(float2 uv)
|
|
{
|
|
float2 centered = uv * 2.0 - 1.0;
|
|
float radius = length(centered);
|
|
float ring = 1.0 - smoothstep(0.015, 0.035, abs(radius - 0.55));
|
|
float cross = 1.0 - smoothstep(0.006, 0.018, min(abs(centered.x), abs(centered.y)));
|
|
return saturate(max(ring, cross));
|
|
}
|
|
|
|
float gridMask(float2 uv)
|
|
{
|
|
float2 cell = abs(frac(uv * max(scale, 1.0)) - 0.5);
|
|
float line = 1.0 - smoothstep(0.455, 0.495, max(cell.x, cell.y));
|
|
return saturate(line * 0.55);
|
|
}
|
|
|
|
float4 buildMask(ShaderContext context)
|
|
{
|
|
float mask = saturate(max(ringMask(context.uv), gridMask(context.uv)));
|
|
return float4(context.sourceColor.rgb, mask);
|
|
}
|
|
|
|
float4 applyMask(ShaderContext context)
|
|
{
|
|
float4 generated = sampleVideo(context.uv);
|
|
float mask = generated.a;
|
|
float checker = step(0.5, frac((context.uv.x + context.uv.y) * max(scale, 1.0)));
|
|
float3 testColor = lerp(float3(0.0, 0.75, 1.0), float3(1.0, 0.1, 0.85), checker);
|
|
float3 base = generated.rgb;
|
|
float3 color = lerp(base, testColor, mask * saturate(intensity));
|
|
return float4(color, 1.0);
|
|
}
|
|
|
|
float4 shadeVideo(ShaderContext context)
|
|
{
|
|
return applyMask(context);
|
|
}
|