| 1 |
/* clang-format off */ |
| 2 |
#[vertex] |
| 3 |
|
| 4 |
#version 450 |
| 5 |
|
| 6 |
#VERSION_DEFINES |
| 7 |
|
| 8 |
layout(location = 0) out vec2 uv_interp; |
| 9 |
/* clang-format on */ |
| 10 |
|
| 11 |
void main() { |
| 12 |
vec2 base_arr[3] = vec2[](vec2(-1.0, -1.0), vec2(-1.0, 3.0), vec2(3.0, -1.0)); |
| 13 |
gl_Position = vec4(base_arr[gl_VertexIndex], 0.0, 1.0); |
| 14 |
uv_interp = clamp(gl_Position.xy, vec2(0.0, 0.0), vec2(1.0, 1.0)) * 2.0; // saturate(x) * 2.0 |
| 15 |
} |
| 16 |
|
| 17 |
/* clang-format off */ |
| 18 |
#[fragment] |
| 19 |
|
| 20 |
#version 450 |
| 21 |
|
| 22 |
#VERSION_DEFINES |
| 23 |
|
| 24 |
layout(location = 0) in vec2 uv_interp; |
| 25 |
|
| 26 |
layout(set = 0, binding = 0) uniform sampler2DMS source_depth; |
| 27 |
|
| 28 |
layout(push_constant, std430) uniform Params { |
| 29 |
ivec2 pad; |
| 30 |
int sample_count; |
| 31 |
int pad2; |
| 32 |
} |
| 33 |
params; |
| 34 |
|
| 35 |
layout (location = 0) out float out_depth; |
| 36 |
|
| 37 |
void main() { |
| 38 |
ivec2 pos = ivec2(gl_FragCoord.xy); |
| 39 |
|
| 40 |
float depth_avg = 0.0; |
| 41 |
for (int i = 0; i < params.sample_count; i++) { |
| 42 |
depth_avg += texelFetch(source_depth, pos, i).r; |
| 43 |
} |
| 44 |
depth_avg /= float(params.sample_count); |
| 45 |
out_depth = depth_avg; |
| 46 |
} |