#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; float t = constants.time * .1f + 0.5f * length( pos ); vec3 color = palette( t, vec3( 0.5, 0.5, 0.5 ), vec3( 0.5, 0.5, 0.5 ), vec3( 2.0, 1.0, 0.0 ), vec3( 0.5, 0.20, 0.25 ) ); imageStore( images[ constants.out_image ], p, vec4( color, 1 ) ); }