I attempted to implement David Makin's fast method for distance estimation. I kind of understand how it works but not exactly, and it's giving me weird results. It seems to be about 5x faster, than my regular method.
Hi Paul, here's a slightly more wordy description "off the top of my head":
For each ray initialise a float array called say "dists" of size maxiter entries each to say 1e200 and set "binary search" count to zero, set "step dstance" to say 1e200 and set current position on the ray then perform the following loop until current position is too large or solid is found
copy "step distance" to last step distance
calculate the values for the current position on the ray
Iterate the fractal formula (==iteration1) store iteration count as i1
if hit max iter
if last step distance==1e200
set "solid found"
set found position=current position
else
set "binary search" count to 1
set step distance = 0.5*last step distance
set current position = current position - step distance
endif
else
calculate s1 = smooth iteration value for iteration1
cacluate values for current position + 1e-10
Iterate the fractal formula (==iteration2)
if hit max iter
if last step distance==1e200
set "solid found"
set found position = current position+1e-10
else
set "binary search" count to 1
set step distance = 0.5*last step distance
set current position = current position+1e-10 - step distance
endif
else
calculate s2 = smooth iteration value for iteration2
calculate v = 1.0/(1.0+1e10*abs(s1-s2))
if v<minimum approach
step distance = 0.5*last step distance
current position = current position - step distance
binary search = 1
else if not binary search
if dists[i1]<v
v = dists[i1]
else
dists[i1] = v
endif
if dists[i1+1]>v
dists[i1+1] = v
endif
step distance = v/(2.5*user detail parameter)
set current position = current position + step distance
else
if binary search count>=max binary depth
set solid found
found position = current position
else
step distance = 0.5*last step distance
if v<minimum approach
current position = current position - step distance
else
current position = current position + step distance
endif
endif
endif
endif
endif
Edit: I just rechecked the original here:
http://www.fractalforums.com/3d-fractal-generation/true-3d-mandlebrot-type-fractal/msg7812/#msg7812 and I think that's actually better
Paul - are you sure you 1. calculated the smooth iteration values correctly ? and 2. used abs(s1-s0) in the DE calculation not just (s1-s0) ?
Edit2: OK, just re-read the original again - there's an error, if the first iteration does not reach max iter but the second does then you need to check to see if it's the first point on the ray (by checking last step distance for instance) and if so then set the point as "found" else if it's not the first point then you *do* need to institute the binary search rather than as I originally wrote it where it's just taken as being the "found" point anyway.