O'Reilly logo

OpenGL 4 Shading Language Cookbook Second Edition by David Wolff

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required