#version 450 /* * Kiyo data * - WORKGROUP_SIZE and NUM_IMAGES are provided by the engine */ layout ( local_size_x = WORKGROUP_SIZE, local_size_y = WORKGROUP_SIZE, local_size_z = 1 ) in; layout( binding = 0, rgba8 ) uniform image2D images[NUM_IMAGES]; layout( push_constant ) uniform PushConstants { float time; int in_image; int out_image; } constants; /* * User data */ void main() { ivec2 p = ivec2( gl_GlobalInvocationID.xy ); ivec2 screenSize = imageSize( images[constants.in_image] ); if( p.x > screenSize.x || p.y > screenSize.y ) { return; } // Blur vec4 c = vec4( 0.0f ); int range = 2; for( int x = -range; x <= range; x++ ) { for( int y = -range; y <= range; y++ ) { ivec2 offset = ivec2( x, y ); vec4 neighbor = imageLoad( images[constants.in_image], p + offset ); c += neighbor; } } c /= pow( range * 2 + 1, 2 ); barrier(); imageStore( images[constants.out_image], p, c ); }