Files
Vibe-HD-2D/assets/shaders/dof_common.glsl
Gabrieal Jimmy 2c99305fb0 init
2026-10-02 12:42:00 -05:00

13 lines
557 B
GLSL

uniform vec4 uDof; // focus distance, focus range, transition, max radius (half-res px)
uniform float uTiltShift;
// Signed CoC in [-1, 1]. Distance-based blur plus an optional screen-space
// tilt-shift band that exaggerates the miniature/diorama look.
float cocFromDepth(float linDepth, vec2 uv) {
float s = linDepth - uDof.x;
float a = smoothstep(uDof.y, uDof.y + uDof.z, abs(s));
float tilt = uTiltShift * smoothstep(0.18, 0.5, abs(uv.y - 0.5));
float sgn = abs(s) > 0.25 ? sign(s) : sign(uv.y - 0.5);
return max(a, tilt) * sgn;
}