Logo by Mahmut - 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. September 19, 2019, 01:48:27 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]   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: About the 4-point DE  (Read 1174 times)
0 Members and 1 Guest are viewing this topic.
JosLeys
Strange Attractor
***
Posts: 258


WWW
« on: March 22, 2013, 08:25:53 PM »

In my attempts to do a better raymarching algorithm in Ultrafractal, I came across the following:

I'm trying to do hybrid fractals without a known analytical DE, so the only option is to use the "four point DE".

It is normally implemented as iterating four points : <x,y,z> (the point on the ray, <x+eps,y,z>, <x,y+eps,z> and <x,y,z+eps>  where eps is a very small number, for instance 10^(-9).
At bailout we have four values for the distance of the iterated point to the origin : R, Rx, Ry, Rz.
The gradient at the point in question is then G=<(R-Rx)/eps, (R-Ry)/eps, (R-Rz)/eps> ( and if normalized, this can be used as the surface normal)

The distance estimate (DE) is then normally calculated from R*log(R)/dR/2, where dR is the length of G.

Two things :

- I find that taking DE=R/dR/2 works just as well and avoids calculating the log function. This is probably cheap in most programs, but every little bit counts!
  ( I find that R*log(R)/dR/8 and R/dR/2 are about equivalent in most cases) 

- Maybe more importantly, the dR vector also gives us an approximate direction towards the closest point on the fractal.
  If this direction is not straight ahead along the ray, we can get away with a bigger fudge factor on the DE!
  Normally one calculates DE and then advances on the ray with a distance DE*ff (ff=fudge factor <1) .
 The cosine of the angle between the ray being marched (along a normalized vector V) and the direction of the closest point is a=dot (V. normalize(G))

We can then take the step on the ray, for instance as step=DE*newff, with newff=ff+(1-ff)*(1-(a+1)/2). (other variations are possible)
This would mean that the fudge factor is indeed the original ff if a=1 (the angle between the ray and the closest point vector is zero : the 'wall' is straight ahead)
If a=0 (the angle is 90░, we are passing parallel to a wall) the ff becomes 0.5*(1+ff). ( if the ff was 0.5 originally, it will then be 0.75)
If a=-1, meaning the 'wall' is directly behind us (which will not happen in practice), ff becomes 1.

Now all this is only useful if ff<1. (if ff=1, newff=ff=1) The smaller ff, the more we gain.
I find in my UF implementation that with ff=0.5, rendering time is 35% shorter. With ff=0.25, the gain is 60% !

I would be very happy if somebody could confirm these results in other programs besides UF ( M3D, Fragmentarium, Mandelbulber...)
Logged
Syntopia
Fractal Molossus
**
Posts: 681



syntopiadk
WWW
« Reply #1 on: March 22, 2013, 10:55:11 PM »

That's a nice idea.

It reminds me of something we discussed some time ago her on the forum: instead of dividing by the length of the gradient, why don't take the derivate in the direction of the ray, and divide by the length of that? (essentially Newtonian root finding). It seems strange that DE's must be non-directional.

Logged
JosLeys
Strange Attractor
***
Posts: 258


WWW
« Reply #2 on: March 22, 2013, 11:14:18 PM »

The directional derivative would imply taking two nearby points in the ray being marched on instead of the four points. This goes back to Dave Makin's original 'delta DE' idea.
The drawback of this is that we now have no gradient that gives us the surface normal, and we need to shoot  at least two adjacent rays to get the normal from a vector cross product.
On the other hand, if the directional derivative would give a more accurate DE, then there are less steps on the ray, and the overall result could be beneficial.

I have not tried it yet..
Logged
David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #3 on: March 24, 2013, 01:13:29 AM »

The idea of modifying the DE based on the directional density should work - in fact the same idea applied to analytical DE may also be optimal even with the extra calcs. involved wink

Personally I'm more interested in a foolproof general (non-analytical) method that will correctly handle discontinuous changes in the potential density - e.g. where there's a hard break that cannot be smoothed - such as in many fractals involving conditionals and in escape-time IFS.
One alternative is to use Ron's "exp" smoothing as a 4-point method but that *is* expensive due to the per-iteration overhead and maybe won't work with escape-time IFS (not sure).
Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
Alef
Fractal Supremo
*****
Posts: 1174



WWW
« Reply #4 on: March 26, 2013, 06:52:57 PM »

I don't know nothing about DE, but there are some simple recriprocal colour algorithms simmilar to exp smoothing, one were in kaliset thread. If Exp smoothing can be used for DE, so maybe alsou some other  sum=sum 1/function(z) type with  computation less expensive function.
Logged

fractal catalisator
Jesse
Download Section
Fractal Schemer
*
Posts: 1013


« Reply #5 on: March 29, 2013, 01:19:07 AM »

Just did some tests, but i have not disabled the small corrections for the DE that are integrated in m3d, so this is not absolute objective  undecided

Used an older kind of testimage proposed by David that gives nice overstepping results for thin planes in various directions.

The attached image shows in the top left corner the default renderer with a fudge factor of 0.3 and the internal DE corrections, that are:
if DE > LastDE + LastStepWidth then DE = LastDE + LastStepWidth
and a fudgefactor decreasement for the opposit case (maximum halve the FF), got the exact formula not in my mind yet but it doesnt got much effect here.

On the right side you see the modifications with a multiplier of 0.5 for the (1- FF) term, so the overall FF can reach up to 0.65.
I just verified the maximal gradient of the 3 directions and calculated the dotproduct for this direction and the actual ray.
In the lower right image i inverted the modification just to see what what happens (instead of (0.5 - 0.5 * dotp) i used 0.5 * dotp).
It shows clearly the advantage in speed over quality that you should do it as proposed  wink

Of course, in all images i used the internal m3d corrections over this modified fudge factors.

But what i would say while done also some attempts for speed improvements is, that if you got bad DE's, you also can't rely on specific gradients or so that are part of the bad DE, so you better rely on well known issues, like if the DE is bigger than the Last DE plus the raystep, you really know that something is wrong  wink


* FFmod.jpg (245.31 KB, 810x660 - viewed 249 times.)
Logged
JosLeys
Strange Attractor
***
Posts: 258


WWW
« Reply #6 on: March 29, 2013, 09:13:37 AM »

Your last comment is important Jesse.
I also found in the meantime that for certain hybrid combinations the speedup scheme fails : too many overshoots, supposedly because the DE in those cases is too inaccurate.
For others it works quite well...
Logged
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Focal Point Images Showcase (Rate My Fractal) thom 1 701 Last post November 25, 2013, 09:32:51 PM
by Dinkydau
What's the point? Images Showcase (Rate My Fractal) thom 0 270 Last post May 04, 2014, 06:42:46 AM
by thom
and the point is what...? Images Showcase (Rate My Fractal) thom 0 449 Last post May 17, 2015, 09:41:53 PM
by thom
directly to the point(s) Images Showcase (Rate My Fractal) thom 4 391 Last post July 23, 2015, 01:07:04 PM
by thom
Turning Point Still Frame - Wildstyle Lambarie 0 206 Last post May 27, 2016, 05:03:55 AM
by Lambarie

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.148 seconds with 27 queries. (Pretty URLs adds 0.022s, 2q)