39 lines
1.1 KiB
GLSL
39 lines
1.1 KiB
GLSL
#version 460 core
|
|
|
|
layout(location = 0) out vec2 outUV;
|
|
layout(location = 1) out vec2 outLoc;
|
|
layout(location = 2) out float cocRadius;
|
|
|
|
layout(binding = 2) uniform sampler2D depthSampler;
|
|
|
|
layout(push_constant) uniform PushConstants {
|
|
vec4 dpack;
|
|
} pushConstants;
|
|
|
|
void main() {
|
|
const vec2 res = vec2(pushConstants.dpack[2], pushConstants.dpack[3]);
|
|
|
|
const vec2 loc = vec2((gl_InstanceIndex % int(res.x)), ((gl_InstanceIndex / int(res.x)) % int(res.y)));
|
|
outLoc = loc;
|
|
|
|
const float depth = texture(depthSampler, vec2(loc.x / res.x, loc.y / res.y)).r;
|
|
float size = 0.0;
|
|
|
|
if(depth > pushConstants.dpack[1])
|
|
size = (depth - pushConstants.dpack[1]) * 500.0 * pushConstants.dpack[0];
|
|
|
|
cocRadius = size;
|
|
|
|
outUV = vec2((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2);
|
|
|
|
vec2 pos = outUV * 2.0 + -1.0;
|
|
pos *= vec2(1.0 / res.x, 1.0 / res.y);
|
|
pos *= min(size, 32.0);
|
|
pos.x -= 1;
|
|
pos.y -= 1;
|
|
pos.x += loc.x / (res.x / 2.0);
|
|
pos.y += loc.y / (res.y / 2.0);
|
|
|
|
gl_Position = vec4(pos, 0.0, 1.0);
|
|
}
|
|
|