Logo by Pauldelbrot - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Check out the originating "3d Mandelbulb" thread here
 
*
Welcome, Guest. Please login or register. March 28, 2024, 08:36:01 PM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: 1 [2]   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: Mandelbuld render glitch  (Read 4056 times)
Description: Something wrong in my formula ?
0 Members and 1 Guest are viewing this topic.
lapinot
Alien
***
Posts: 25


« Reply #15 on: February 15, 2015, 05:32:31 PM »

I just tried to improve the rendering speed using Quilez optimization and I get:



The (working) code I used for the images above was:

Code:
long double DistanceEstimators::CPPDE (D3Vec w) {

D3Vec z = w;
float wr = w.getLength();
float dr = 1.0;

int escape = 20;
int Power = 4;
//double Scale = 1;

// Iterate
for (int i = 0; i != 10 && wr < escape; i++) {

// extract polar coordinates
//float wr = std::sqrt(w * w);
float wo = std::acos(w.y / wr);
float wi = std::atan2(w.x, w.z);
dr = std::pow(wr, Power - 1) * Power * dr + 1;

// scale and rotate the point
wr = std::pow(wr, Power);
wo = wo * Power;
wi = wi * Power;

// convert back to cartesian coordinates
w.x = std::sin(wo) * std::sin(wi);
w.y = std::cos(wo);
w.z = std::sin(wo) * std::cos(wi);
w = w * wr;

// add starting point to new point
w = w + z;
wr = w.getLength();

// running derivative
//std::cout << "#step " << i << ": " << dr << std::endl;
}

// Back
return std::min(1.0, 0.5 * std::log(wr) * wr / dr);
}

And the one with Quilez optimization:

Code:
long double DistanceEstimators::CPPDE (D3Vec w) {

D3Vec c = w;
long double wr = w.getLength();
long double dr = 1.0;

int escape = 20;
int Power = 4;
//double Scale = 1;

// Iterate
for (int i = 0; i != 10 && wr < escape; i++) {

// running derivative
dr = std::pow(wr, Power - 1) * Power * dr + 1;

// quilez optimization
long double x = w.x; long double x2 = x*x; long double x4 = x2*x2;
long double y = w.y; long double y2 = y*y; long double y4 = y2*y2;
long double z = w.z; long double z2 = z*z; long double z4 = z2*z2;

long double k3 = x2 + z2;
long double k2 = 1.0L / std::sqrt(k3*k3*k3*k3*k3*k3*k3);
long double k1 = x4 + y4 + z4 - 6.0*y2*z2 - 6.0*x2*y2 + 2.0*z2*x2;
long double k4 = x2 - y2 + z2;

w.x =  64.0*x*y*z*(x2-z2)*k4*(x4-6.0*x2*z2+z4)*k1*k2;
w.y = -16.0*y2*k3*k4*k4 + k1*k1;
w.z = -8.0*y*k4*(x4*x4 - 28.0*x4*x2*z2 + 70.0*x4*z4 - 28.0*x2*z2*z4 + z4*z4)*k1*k2;

// scale w
wr = std::pow(wr, Power);
w = w * wr;

// add starting point to new point
w = w + c;
wr = w.getLength();
}

// Back
return std::min(1.0L, 0.5 * std::log(wr) * wr / dr);
}

I basically tried to insert the modification into the previous code. And checked that my vars are initialized in the correct order regarding previous code but there's a mistake.
Logged
eiffie
Guest
« Reply #16 on: February 15, 2015, 06:45:13 PM »

Glad you got it working! I would stick with the version that lets you adjust the power easily. When you switch from CPU to GPU it will be plenty fast.
Logged
lapinot
Alien
***
Posts: 25


« Reply #17 on: February 15, 2015, 09:43:33 PM »

Yes you're right.. Actually I even mixed Powers 4 and 8 in the formula. With only power 8 I still get the same kind of image tho. I'll save it for later maybe smiley
Logged
lapinot
Alien
***
Posts: 25


« Reply #18 on: February 17, 2015, 06:24:17 PM »

Trying to improve my raymarcher's escape condition and I got:





Funny pics  grin
Logged
Pages: 1 [2]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
glitch 3D Fractal Generation lycium 0 1580 Last post February 26, 2008, 12:50:25 AM
by lycium
1.7.3 Animation glitch? Mandelbulb 3d muchogrande 4 8788 Last post August 04, 2011, 12:42:30 AM
by Jesse
Pause render, save project and continue render from the same spot, possible? Mandelbulb 3d dissolvingstudios 5 6774 Last post January 25, 2012, 06:33:32 AM
by taurus
Mandelbuld 3D v1.8.6 beta test Releases « 1 2 ... 5 6 » Jesse 86 24628 Last post September 15, 2013, 06:26:25 AM
by 0Encrypted0
Mandelbox render glitch 3D Fractal Generation lapinot 2 2593 Last post September 19, 2015, 02:21:42 PM
by lapinot

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.257 seconds with 24 queries. (Pretty URLs adds 0.009s, 2q)