44 lines
983 B
GLSL
44 lines
983 B
GLSL
// MinecraftPT — Dof_FS
|
|
// Depth of field with circle of confusion bokeh.
|
|
|
|
#include "/Lib/Settings.glsl"
|
|
#include "/Lib/Utilities.glsl"
|
|
#include "/Lib/IndividualFunctions/DOF.glsl"
|
|
|
|
uniform sampler2D colortex12;
|
|
|
|
layout(location = 0) out vec4 colorOut;
|
|
|
|
void main(){
|
|
vec2 texelCoord = gl_FragCoord.xy;
|
|
|
|
vec3 color = texelFetch(colortex12, ivec2(texelCoord), 0).rgb;
|
|
|
|
#ifdef DOF
|
|
if (DOF > 0){
|
|
float depth = texelFetch(depthtex0, ivec2(texelCoord), 0).r;
|
|
|
|
// Focal distance (from center depth or manual)
|
|
float focalDepth = CAMERA_FOCAL_POINT;
|
|
#ifdef CAMERA_FOCUS_MODE
|
|
if (CAMERA_FOCUS_MODE == 1){
|
|
vec2 center = screenSize * 0.5;
|
|
focalDepth = texelFetch(depthtex0, ivec2(center), 0).r;
|
|
}
|
|
#endif
|
|
|
|
float coc = GetCoC(depth, focalDepth);
|
|
|
|
#ifdef DISABLE_HAND_DOF
|
|
// Skip hand (close depth)
|
|
if (depth < 0.1) coc = 0.0;
|
|
#endif
|
|
|
|
if (coc > 0.5){
|
|
color = DofBlur(texelCoord, coc);
|
|
}
|
|
}
|
|
#endif
|
|
|
|
colorOut = vec4(color, 1.0);
|
|
} |