top of page

# Fractal Art Experiment Using VEX Code:   My first attempt at recreating Entagma's Mandelbulb and Mandelbrot Fractal design (https://vimeo.com/176911687).

After spending some time studying Python and C++, I was finally able to wrap my head around VEX and attempt a few more complex tutorials. Entagma's VEX tutorials have always been great to understand better applications of Coding in Houdini and this was a good opportunity to understand the Volume Wrangle as well.

I am writing the code for anyone who would like to take a look at it and probably add a few more twists and takes to it.

//--- function ---

function int Mandel(float x0, y0, z0; int imax) {     float x = 0, y = 0, z = 0, xnew = 0, ynew = 0, znew = 0, n = ch("n"), r = 0, theta = 0, phi = 0;     for(int i = 0 ; i < imax; i++)     {         //xnew = x*x - y*y + x0;         //ynew = 2*x*y + y0;         r = sqrt(x*x + y*y+ z*z);         theta = atan2(sqrt(x*x + y*y), z);         phi = atan2(y,x);         xnew = pow(r, n) * sin(theta*n) * cos(phi*n) + x0;         ynew = pow(r, n) * sin(theta*n) * sin(phi*n) + y0;         znew = pow(r,n) * cos(theta*n) + z0;         if(xnew*xnew + ynew*ynew + znew*znew > 8)         {             return(i);         }         x = xnew;         y = ynew;         z = znew;     }     return(imax); }

//---main--- int maxiter = chi("maxiter");

if(Mandel(@P.x, @P.y,@P.z,maxiter) < maxiter) {     @density = 0.0; } else {     @density = 1.0; }