Perform the following steps:
- In the compute shader, we start by defining the number of shader invocations per work group:
layout( local_size_x = 32, local_size_y = 32 ) in;
- Next, we declare the output image as well as some other uniform variables:
layout( binding = 0, rgba8) uniform image2D ColorImg; #define MAX_ITERATIONS 100 uniform vec4 CompWindow; uniform uint Width = 256; uniform uint Height = 256;
- We define a function to compute the number of iterations for a given position on the complex plane:
uint mandelbrot( vec2 c ) { vec2 z = vec2(0.0,0.0); uint i = 0; while(i < MAX_ITERATIONS && (z.x*z.x + z.y*z.y) < 4.0) { z = vec2( z.x*z.x-z.y*z.y+c.x, 2 * z.x*z.y + c.y ); i++; } return i; }
- In the main function, we ...