Skip to content

This project is a Fractal Visualizer developed in C++ with SFML and CUDA.

License

Notifications You must be signed in to change notification settings

dpetrosy/Fractal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

75 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation


๐Ÿ“œ About Project

A fractal is a fragmented geometrical figure that infinitely repeats at smaller scales.
So this project generates beautiful fractals from the complex numbers of an iterative mathematical construct.
For graphics, I used SFML library and NVIDIA CUDA Toolkit for parallel computing.
Project builds by CMake build system, so if you do not have CUDA Toolkit or your platform doesn't have CUDA support, CMake will build this project without CUDA support and computing will be done through CPU threads.
By default, there will be 40 parallel threads, the color is rgb(21, 0, 0) and the window size is 800px.

Note

If you want to change color, threads count, window size, or other defaults, change them in helpers.hpp file.

๐Ÿ“‘ Fractals List

The program supports these fractal sets:

Name Formula
Mandelbrot $z_{n+1} = z_n^2 + c, z_0 = 0$
Julia $z_{n+1} = z_n^2 + c, z_0 = c$
Burning Ship $z_{n+1} = abs(z_n^2) + c, z_0 = 0$
Tricorn $z_{n+1} = \overline{z_n}^2 + c, z_0 = 0$
Mandelbox It's more complex, see this article
Multibrot $z_{n+1} = z_n^d + c, z_0 = 0, d = 5$
Mandelbar Take a look at Mandelbar 5th (horizontal) in this image
Per. Burning Ship Take a look at Perpendicular Burning Ship in this image
Celtic Mandelbrot Take a look at Celtic Mandelbrot in this image

Useful Links:

https://www.deviantart.com/kosmic-stardust/art/Mandelbrot-ABS-Variations-Complete-Set-of-Formulas-487039852 https://www.deviantart.com/kosmic-stardust/art/4th-Order-ABS-Mandelbrot-Variations-Complete-Set-601300868 https://www.deviantart.com/kosmic-stardust/art/5th-Order-ABS-Mandelbrot-Variations-601484985

๐ŸŽฎ Controls

The program supports the following controls:

Key Description
ESC Close the program window
Keys [1-9] Move to another fractal
Key R Change the red component of fractal
Key G Change the green component of fractal
Key B Change the blue component of fractal
Mouse Scroll Zoom in and out of the fractal
โฌ†๏ธ โฌ‡๏ธ โฌ…๏ธ โžก๏ธ Change the viewpoint
Key L Lock Julia's fractal
Zero Reset the fractal to its initial state

๐Ÿ‘จโ€๐Ÿ’ป Usage

Requirements

The program is written in C++ and thus needs the g++ compiler and some standard C++ libraries to run.
Also needs to install SFML library and CMake. If you want to use your NVIDIA GPU power, you need to install NVIDIA CUDA Toolkit.

Instructions

1. Compiling the program

To build the release version, run these commands:

$ cd path/to/fractal
$ mkdir Release
$ cd Release
$ cmake -DCMAKE_BUILD_TYPE=Release ..
$ make

To build the debug version, run these commands:

$ cd path/to/fractal
$ mkdir Debug
$ cd Debug
$ cmake -DCMAKE_BUILD_TYPE=Debug ..
$ make

2. How to run the program

Run the executable too see the help message:

./fractal

Or run with some supported fractal:

./fractal mandelbrot

Note

For CUDA support, you need to install CMake version >= 3.24
If you want to disable CUDA support, just uncommnet line 19 in CMakeLists.txt file.

๐ŸŒ„ Screenshots

Mandelbrot

Fractal Mandelbrot Fractal Mandelbrot

Julia

Fractal Julia

Burning Ship

Fractal Burning Ship

Tricorn

Fractal Tricorn

Mandelbox

Fractal Mandelbox

Multibrot

Fractal Multibrot

Mandelbar

Fractal Mandelbar

Perpendicular Burning Ship

Fractal Perpendicular Burning Ship

Celtic Mandelbrot

Fractal Celtic Mandelbrot