It now works correctly, and will output a "proper" depth of field effect. There's still work to be done to make it look smoother, but it's already pretty convincing.
29 lines
882 B
GLSL
Executable file
29 lines
882 B
GLSL
Executable file
#version 460 core
|
|
|
|
layout(location = 0) in vec2 inUV;
|
|
layout(location = 1) in vec2 inPos;
|
|
layout(location = 2) in float cocRadius;
|
|
|
|
layout(location = 0) out vec4 outColor;
|
|
|
|
layout(binding = 0) uniform sampler2D bokehSampler;
|
|
layout(binding = 1) uniform sampler2D sceneSampler;
|
|
layout(binding = 2) uniform sampler2D depthSampler;
|
|
|
|
layout(push_constant) uniform PushConstants {
|
|
vec4 dpack;
|
|
vec4 dpack2;
|
|
int reverse;
|
|
} pushConstants;
|
|
|
|
void main() {
|
|
const vec2 res = vec2(pushConstants.dpack[2], pushConstants.dpack[3]);
|
|
|
|
// bokeh luminance is also based off of Bart Wronski's work.
|
|
const vec3 bokehSample = texture(bokehSampler, inUV).rgb;
|
|
const float lum = dot(bokehSample, vec3(0.299, 0.587, 0.114));
|
|
|
|
outColor.rgb = bokehSample * texture(sceneSampler, vec2(inPos.x / res.x, inPos.y / res.y)).rgb * cocRadius;
|
|
outColor.a = cocRadius * lum;
|
|
}
|
|
|