Creating a fractal texture using the compute shader
We'll wrap up this chapter with an example that makes use of the compute shader to produce an image of a fractal. We'll use the classic Mandelbrot set.
The Mandelbrot set is based on iterations of the following complex polynomial:
Where z and c are a complex numbers. Starting with the value z = 0 + 0i, we apply the iteration repeatedly until a maximum number of iterations is reached or the value of z exceeds a specified maximum. For a given value of c, if the iteration remains stable (z doesn't increase above the maximum) the point is inside the Mandelbrot set and we color the position corresponding to c black. Otherwise, we color the point based on the number of iterations it took for the value to exceed the maximum.
In the following figure, the image of the Mandelbrot set is applied as a texture to a cube:
We'll use the compute shader to evaluate the Mandelbrot set. Since this is another image-based technique, we&apos...