#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( binding = 1, r32ui ) uniform uimage2D counterImages[3];
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) );
}
float gold_noise(vec2 xy, float seed) {
return fract(tan(distance(xy * 1.61803398874989484820459, xy) * seed) * xy.x);
}
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;
}
uint r = imageLoad(counterImages[0], p).r;
uint g = imageLoad(counterImages[1], p).r;
uint b = imageLoad(counterImages[2], p).r;
vec3 color = vec3(r, g, b) / 9900.0;
imageStore( images[ constants.out_image ], p, vec4( color, 1 ) );
}