38 lines
951 B
Plaintext
38 lines
951 B
Plaintext
#version 450
|
|
|
|
layout (binding = 0, rgba32f) uniform writeonly image2D image;
|
|
|
|
layout (push_constant) uniform constants
|
|
{
|
|
uint width;
|
|
uint height;
|
|
} PushConstants;
|
|
|
|
layout (local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
|
void main()
|
|
{
|
|
vec2 pos = vec2(float(gl_GlobalInvocationID.x) / float(PushConstants.width) - 0.5f, float(gl_GlobalInvocationID.y) / float(PushConstants.height) - 0.5f) * 3.f;
|
|
|
|
int iter = 0;
|
|
float re = 0;
|
|
float im = 0;
|
|
while(iter < 200)
|
|
{
|
|
float new_im = pos.y + 2. * re * im;
|
|
float new_re = pos.x + (re * re - im * im);
|
|
re = new_re;
|
|
im = new_im;
|
|
|
|
if(re * re + im * im > 4.f)
|
|
{
|
|
float c = float(iter) / 200;
|
|
imageStore(image, ivec2(gl_GlobalInvocationID.xy), vec4(c, 0.2, 1.0 - c, 1.0));
|
|
|
|
return;
|
|
}
|
|
iter += 1;
|
|
}
|
|
|
|
imageStore(image, ivec2(gl_GlobalInvocationID.xy), vec4(0.f));
|
|
}
|