Jump to content

machinainfinitum

Members
  • Content count

    3
  • Donations

    0.00 CAD 
  • Joined

  • Last visited

Community Reputation

0 Neutral

About machinainfinitum

  • Rank
    Peon

Personal Information

  • Name
    Machina Infinitum
  1. HOUDINI - VEX - OSL CONVERSION

    This works perfectly ! Thanks so much! Now I'll try to convert all the formulas I have
  2. HOUDINI - VEX - OSL CONVERSION

    Thanks I need to convert all my existing OSL fractals code to VEX. Than I can mesh the VEX fractal and use it as dummy obj on top of Octane Vectron fractals
  3. HOUDINI - VEX - OSL CONVERSION

    I’m looking for someone who can convert some OSL code to VEX code. I have a fractal formula written in OSL that needs to be volume density output VEX. For now the simple mandelbulb fractal conversion is enough but I'm looking for someone that could convert many other complex formulas.(200-300 lines of code). New to Houdini, and can't find a way to get this working...after days of looking around, this forum is my last option. OSL CODE TO CONVERT: shader OslGeometry( int Iterations = 10, float Power = 2.0, float Bailout = 20, output _sdf c = _SDFDEF) { vector pos = P; vector z = P; float dr = 1.0; float r = 0.0; for (int i = 0; i < Iterations ; i++) { r = length(z); if (r>Bailout) break; // convert to polar coordinates float theta = acos(z[2]/r); float phi = atan2(z[1],z[0]); dr = pow( r, Power-1.0)*Power*dr + 1.0; // scale and rotate the point float zr = pow( r,Power); theta = theta*Power; phi = phi*Power; // convert back to cartesian coordinates z = zr*vector(sin(theta)*cos(phi), sin(phi)*sin(theta), cos(theta)); z+=pos; } c.dist = 0.5*log(r)*r/dr; } OSL CODE THAT WORKS BUT NEED IT TO BE LIKE THE OSL: function int Mandel(float x0, y0, z0; int Iterations){ float x, y, z, xnew, ynew, znew, n=ch('n'), r, theta, phi; int i; x = x0; y = y0; z = z0; for(i=0; i < Iterations; i++){ 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(Iterations); } //--- Main --- int maxiter = 8; if(Mandel(@P.x, @P.y, @P.z, maxiter) < maxiter){ @density = 0.0; } else { @density = 1.0; } AAND MY CONVERSION THAT DOES NOT WORK function int Fractal(int Iterations, float Power, float Bailout, vector pos, vector z, float dr, float r){ for (int i = 0; i < Iterations ; i++) { r = length(z); if (r>Bailout) break; // convert to polar coordinates float theta = acos(z.z/r); float phi = atan2(z.y,z.x); dr = pow( r, Power-1.0)*Power*dr + 1.0; // scale and rotate the point float zr = pow( r,Power); theta = theta*Power; phi = phi*Power; // convert back to cartesian coordinates z = zr*vector(sin(theta)*cos(phi), sin(phi)*sin(theta), cos(theta)); z+=pos; } return 0.5*log(r)*r/dr; } int Iterations = 10; float Power = 2.0; float Bailout = 20; vector pos = @P; vector z = @P; float dr = 1.0; float r = 0.0; if(Fractal(Iterations,Power,Bailout,@P,@P,dr,r) < Iterations){ @density = 0.0; } else { @density = 1.0; } Thanks in advance. Cheers, Scappin Matteo www.machina-infinitum.com
×