#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 */ vec3 palette( in float t, in vec3 a, in vec3 b, in vec3 c, in vec3 d ) { return a + b*cos( 6.28318*(c*t+d) ); } void main() { ivec2 p = ivec2( gl_GlobalInvocationID.xy ); ivec2 screenSize = imageSize( images[ constants.out_image ] ); if( p.x > screenSize.x || p.y > screenSize.y ) { return; } vec2 pos = vec2( float( p.x ) / float( screenSize.x ), float( p.y ) / float( screenSize.y ) ) - 0.5f; // Kernel setup vec3 edge = vec3( 0.0 ); vec3 center = vec3( 5.0 ); vec3 corner = vec3( -1.0 ); vec3 total = edge * 4. + corner * 4. + center; edge /= total; center /= total; corner /= total; vec3 kernel[9] = { corner, edge, corner, edge, center, edge, corner, edge, corner }; vec4 c = vec4( 0.0f ); int range = 1; for( int x = -range; x <= range; x++ ) { for( int y = -range; y <= range; y++ ) { c += imageLoad( images[constants.in_image], p + ivec2( x, y ) ) * vec4(kernel[ x + range + ( y + range ) * 3 ], 1); } } imageStore( images[ constants.out_image ], p, c ); }