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:

Creating a fractal texture using the compute shader

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 ...

Get OpenGL – Build high performance graphics now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.