Skip to content

RodrigoPAml/MandelbrotFractal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mandelbrot Fractal

Implementation of Mandelbrot Fractal using Box Engine with Lua and GLSL

Box engine is developed by me to create 2D and 3d applications

Show case

2

Fractal below have the credits to https://www.shadertoy.com/view/tllSWj

222

How to use

  • Space/Z to zoom in/out
  • Q to change between fractals variants
  • Move with arrows

Implementation

The Mandelbrot set is a collection of points in the complex plane. Each point (c) is a complex number represented as (c = x + yi) (where (x) and (y) are real numbers, and (i) is the imaginary unit).

To check if a point (c) is in the Mandelbrot set, we repeatedly apply a formula and see if the result gets very large (tends to infinity). If it does, the point is not in the set. If it doesn't, the point is in the set.

Here's the basic GLSL code that does this:

    for (int i = 0; i < max_iterations; i++) 
    {
        if (length(z) > 8.0) {
            break;
        }
        
        z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c; // iteration formula
        
        iterations++;
    }

    if (iterations == max_iterations) 
    {
        fragColor = vec4(0, 0 , 0, 1.0); // outside
    }
    else
    {
        fragColor = (float(iterations)/float(max_iterations)); // inside
    }

Executing

  • Box Engine is available in Engine Folders with a release and the source code is in my repository (note that versions might differ)
  • To run use start.bat or use start_editor.bat to use the engine editor and change settings better
  • The complete source code of the fractal is in Assets folder

image

About

Implementation of Mandelbrot fractal using BoxEngine

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published