init
This commit is contained in:
12
assets/shaders/dof_common.glsl
Normal file
12
assets/shaders/dof_common.glsl
Normal file
@@ -0,0 +1,12 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user