MandelBulb Help

   984   0   0
User Avatar
Member
1 posts
Joined: Jan. 2015
Offline
I'm currently learning about MandelBulbs via shader cvex, many thanks to Entagma and Thomas Dotheij.


My problem is how do you animate using $FF (or a better method) in the cvex snippet?

function int Mandel(float x0, y0, z0, n; int imax){
    float x, y, z, xnew, ynew, znew, r, theta, phi;
    int i;
    x = x0;
    y = y0;
    z = z0;
        
    for(i=0; i < imax; i++ && timer++){
        //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 ---
if(Mandel(@P.x, @P.y, @P.z, limit, maxiter) < maxiter){
    @density = 0.0;
    
}
else {
    @density = 1.0;
    
}
  • Quick Links