Archived
1
Fork 0
This repository has been archived on 2025-04-12. You can view files and clone it, but cannot push or open issues or pull requests.
graph/shaders/dof.frag

30 lines
882 B
GLSL
Raw Normal View History

2018-11-03 07:24:32 -04:00
#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;
2018-11-03 07:24:32 -04:00
} 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));
2018-11-03 07:24:32 -04:00
outColor.rgb = bokehSample * texture(sceneSampler, vec2(inPos.x / res.x, inPos.y / res.y)).rgb * cocRadius;
outColor.a = cocRadius * lum;
2018-11-03 07:24:32 -04:00
}