Debian Codegraph @

servers/rendering/renderer_rd/shaders/effects/motion_vectors_store.glsl

raw
1 #[compute]
2
3 #version 450
4
5 #VERSION_DEFINES
6
7 #include "motion_vector_inc.glsl"
8
9 layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
10 layout(set = 0, binding = 0) uniform sampler2D depth_buffer;
11 layout(rg16f, set = 0, binding = 1) uniform restrict writeonly image2D velocity_buffer;
12
13 layout(push_constant, std430) uniform Params {
14 highp mat4 reprojection_matrix;
15 vec2 resolution;
16 uint pad[2];
17 }
18 params;
19
20 void main() {
21 // Out of bounds check.
22 if (any(greaterThanEqual(vec2(gl_GlobalInvocationID.xy), params.resolution))) {
23 return;
24 }
25
26 ivec2 pos = ivec2(gl_GlobalInvocationID.xy);
27
28 float depth = texelFetch(depth_buffer, pos, 0).x;
29 vec2 uv = (vec2(pos) + 0.5f) / params.resolution;
30 vec2 velocity = derive_motion_vector(uv, depth, params.reprojection_matrix);
31 imageStore(velocity_buffer, pos, vec4(velocity, 0.0f, 0.0f));
32 }