#version 450
layout ( local_size_x = 16, local_size_y = 16, local_size_z = 1 ) in;
layout( binding = 0, rgba8 ) uniform image2D image;
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( 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 = .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( image, p, vec4( color, 1 ) );
}