Logo by mauxuam - 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: Follow us on Twitter
 
*
Welcome, Guest. Please login or register. April 19, 2024, 02:23:57 AM


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: DragonKIFS - promising formula but help needed  (Read 17846 times)
0 Members and 1 Guest are viewing this topic.
Kali
Fractal Supremo
*****
Posts: 1138


« on: October 16, 2012, 07:31:14 AM »

Some time ago I made this to test the possibility of making image-based IFS using flash:  (move the mouse over it to change fractal shape)

<a href="https://dl.dropbox.com/s/7h98zkj3pj3zlvm/ifs2.swf" target="_blank">https://dl.dropbox.com/s/7h98zkj3pj3zlvm/ifs2.swf</a>

I made it by using an array of movieclips and a recursive routine that makes two smaller copies of the previous generation of images, placed at 180º from each other (taking the base image as the center and the copies orbiting around it). Then the fractal is made easy, by simply changing the position angle of the copies after each iteration.

I wanted to see if I could make a 3D version of this fractal in Fragmentarium using baseshapes (i.e. spheres), but I encountered a problem as the GPU can't handle big arrays. Anyway, with the method I used in flash, anything beyond a few iterations gets really slower and memory consuming (you have to treat each of the parts that are duplicated as a variable and establish their scale and positions individually).

I moved to the idea of finding a folding for this kind of fractal, so I can make an escapetime version. And I found a way, but there's a problem...


I started from the simpler version of abs folding, that works this way:





(The example shows the first iteration of a fractal made of spheres that are drawn using min.DEcombinate method evaluated at each iteration, and I only take x-axis folding and 2D transforms to make the things simpler...)


So a fractal made with this folding iterates the following procedure:

- Fold X (abs)
- Scale
- Translate (constant C, as shown in the image, often called "Julia values")



After some iterations the result is:





And adding some rotation at each iteration:





With this method, the spheres from each side sometimes will overlap at the line of symmetry (as you can see in the example at the right), making a discontinuity in the baseshape used, but not in the fractal itself as each side always meets exactly the opposite (something you may always expect in a reflection transform grin). So there are no shape/empty-space discontinuity.

Let's see what happens in the solution I found for the DragonKIFS folding:





So the iteration procedure is:

- If X>0, invert Y (Y=-Y)
- ABS(X)  (the reflected copy will be placed at 180º degrees because of the inversion of the other half of the fractal)
- Scale
- Translate (by C constant)
- Rotate
- Invert X (this gives the next copy the right orientation)


The result using some rotation angle is:






Seems to be working right, but...

If the iterated parts trespass the "abs barrier" formed by the axis of symmetry, this is what happens:





So you can see the fractal shape is truncated, also disturbing the distance estimator because of this discontinuity (I didn't made an image of the DE problem, but believe me grin)
Off course, as you can see, this also happens with all the child shapes at it's own abs fold axis.

Damn... never see it coming, even when it's obvious this was going to happen angry

However, using the pure escapetime version of the fractal, I managed to get some decent renderings... using "fudge factor" option of Fragmentarium and progressive rendering helped a lot with the DE trouble... and even I think the discontinuity contributes aesthetically sometimes...

But I still want to make the fractal right, in the way I was looking for. Also I want to make a proper baseshape version to be included in my KDIFS script, and it's when the DE issue is really a problem, because even when the fractal "arms" don't trespass the abs fold line, the DE fails when looking from certain angles... I guess this is caused by the discontinuity even in the empty space, because of the change of sign.


So, if someone has an idea on how to make it right, I'll appreciate your help. Keep in mind that I want only an escapetime version of it.

Thank you in advance!


In the posts below there are some quick renders I made to show the formula's potential, and there is another one in the gallery:

http://www.fractalforums.com/index.php?action=gallery;sa=view;id=12561

« Last Edit: October 16, 2012, 07:33:29 AM by Kali » Logged

Kali
Fractal Supremo
*****
Posts: 1138


« Reply #1 on: October 16, 2012, 07:40:19 AM »


DragonKIFS - X version:






DragonKIFS - XY version:




Logged

DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #2 on: October 16, 2012, 01:08:54 PM »

 grin Congrats, you found the good old 3D Barnsley. wink It is an old problem...
Logged

No sweat, guardian of wisdom!
Kali
Fractal Supremo
*****
Posts: 1138


« Reply #3 on: October 17, 2012, 04:57:54 AM »

grin Congrats, you found the good old 3D Barnsley. wink It is an old problem...

Yep, it seems like I ended up with something similar to Mr. Barnsley's conditional formula, but I didn't think of it, I just made it as I show in the post.
Anyway I did a search and I didn't found any "3D Barnsley" image that looks remotely similar to the renderings I've done, and you call it the "good old 3D Barnsley", did I miss something?
Logged

Kali
Fractal Supremo
*****
Posts: 1138


« Reply #4 on: October 17, 2012, 06:47:40 AM »

I did a 3D version of the original Barnsley formula, and it does give some similar results indeed:





Original Barnsley multiplies by complex number which is the same as scaling+rotate so the simplified formula I used here is:

p.x=p.x-sign(p.x); // the same as (if x>0 x=x-1 else x=x+1) but more elegant wink
p*=Scale;
p*=Rotation;

Where "Rotation" is the 3D rotation matrix defined with rotationMatrix3 function in Fragmentarium


The discontinuities are somehow more noticeable with most params using this formula, not the same shapes can be achieved, and all in all I think my formula works better...
But yes, I have to admit that mine is a kind of 3D Barnsley, even when is not the same at all...

I insist, what I don't understand is, if it's a well-known 3D fractal, why I can't find other 3D Barnsley renders like this, or some references to this 3D version?

« Last Edit: February 28, 2013, 06:40:11 PM by Kali » Logged

DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #5 on: October 17, 2012, 12:50:42 PM »

My implements are not as sharp as yours, and it's hard to manage it. Your rensers are much more detailed. A Beer Cup
Logged

No sweat, guardian of wisdom!
eiffie
Guest
« Reply #6 on: October 17, 2012, 05:11:21 PM »

Kali could you try rotating the fold with each iteration instead? This may be a dumb idea but I will try it out.
Logged
Kali
Fractal Supremo
*****
Posts: 1138


« Reply #7 on: October 18, 2012, 03:23:13 AM »

Ok, I totally misunderstood what Darkbeam wrote, I thought he was being sarcastic, sorry Luca! embarrass
When he said the "good old 3D Barnsley" I interpreted that the results of my formula were something already known, but he meant it's an old problem to get a good 3D result of something like Barnsley conditional formula does in 2D. However Luca was pretty close with his 4D Barnsley in Mandelbulb3D.

Kali could you try rotating the fold with each iteration instead? This may be a dumb idea but I will try it out.

Yes, is one of the things I tried, but don't know if I did it right... maybe rotate, fold, and then rotateback?
Logged

DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #8 on: October 18, 2012, 09:54:29 AM »

I report here my concept of what Barnsley formula does. embarrass Don't know it's really correct.

- A complex number can be thinked as an affine transform, simplified as rotation and scale (when we multiply), translation (when we add).
- In Julia mode, Barnsley formula is a pure IFS fractal;

  IF real(z) >= 0 // real(z) = x coordinate
    z = (z - 1) * pixel
  ELSE
    z = (z + 1) * pixel
  ENDIF

As pixel stays constant in J-mode this is a conditional translation, and an unconditional fixed rotation

  IF x >= 0
    z = z - 1 // translation
  ELSE
    z = z + 1 // translation
  ENDIF
    z = z * pixel // rotation

Hope this helps. A Beer Cup In 3D we need a triple angle, and a 3D translation- easier said than done btw. A Beer Cup
Logged

No sweat, guardian of wisdom!
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #9 on: October 18, 2012, 10:23:01 AM »

uH! Just readed of your issue - it is (too) an old issue. The issue! wink The only way to solve it is to use a probabilistic approach; in other words, the fractal would be rendered as a cloud of pixels like in Incendia. A Beer Cup

The method you are using is called "brute force", it does not work well for all kinds of transforms.

ps; there is also a way to work this around *but* it seems to be absolutely complicated. Dave Makin made a very accurate 2d formula but I simply can not understand it at all! alien alien alien
Logged

No sweat, guardian of wisdom!
Kali
Fractal Supremo
*****
Posts: 1138


« Reply #10 on: October 19, 2012, 08:30:14 AM »

This are Fragmentarium .frag files for DragonKIFS and Barnsley3D formulas, including some presets.
Use with latest version: https://github.com/downloads/Syntopia/Fragmentarium/Fragmentarium%20Windows%20Binary%20v0.9.12b2.zip


* DragonKIFS.frag (6.86 KB - downloaded 601 times.)
* Barnsley_3D.frag (3.62 KB - downloaded 592 times.)
Logged

eiffie
Guest
« Reply #11 on: February 07, 2013, 06:09:28 PM »

OK I finally found a "solution". But I doubt anyone will like it smiley When we have a discontinuous cut plane (where the fractal follows different orders on either side) we can correct our DE by limiting the return value so we never jump to the other side of the plane but instead step nicely over the boundary a small amount then perform the next DE from that side.

The problem is that means making the formula linear and doing a strange combination of ray-marching/tracing. Here are examples:
Code:
float DistanceToPlane(vec3 p, vec3 nrm, vec3 rd)
{//exact distance to plane (from either side)
float t=-(dot(nrm,p))/dot(nrm,rd); //needs the ray direction!!!
if(t<0.0)return 1000.0;
return t;
}
float DDE(vec3 p, vec3 rd, out bool bHit) //the point to test, ray direction, did we hit the object or just a plane
{//directional distance estimate?!? (best or worst of two worlds?)
float dP=1000.0;
for (int i = 0; i < iters; i++) {
dP=min(dP,DistanceToPlane(p,normalize(c[i]),rd));
p-=c[i]*sign(dot(p,c[i]));//c is a precalculated array of offsets
}
float dS=max(0.0005,length(p)-radius);//leaving room for the calculation of a normal
bHit=(dS<0.001);//bHit tells if we hit the surface or we are just close to a cut plane
return min(dS,dP+0.00001);//step over the plane
}

There are some nice things about this - precalculated offsets so you do the math once, works with any discontinuous cut.
But also many bad things sad - need to make the formula linear (don't scale/rotate p just c), at high iterations the march becomes too slow (too many planes limiting movement).  
You could also scale and rotate the ray direction along with p. That would make calculating the distance to the plane simpler.
Whatever smiley just wanted to show it can be done - the question is do we really want to?


* dragonCutFix.jpg (25.74 KB, 320x273 - viewed 5659 times.)
« Last Edit: February 07, 2013, 06:12:48 PM by eiffie » Logged
Kali
Fractal Supremo
*****
Posts: 1138


« Reply #12 on: February 08, 2013, 01:35:38 AM »

Nice work, eiffie, all in all is a nice workaround, thanks for sharing!
Logged

Kali
Fractal Supremo
*****
Posts: 1138


« Reply #13 on: March 06, 2013, 12:53:19 AM »

I finally found a way to properly render a 3D dragon fractal made of base shapes in Fragmentarium.

I made this test image using spheres:



I used a section of the screen and the buffer to pre-calculate the positions of each generation of spheres. The colorful garbage you can see on the lower part of the image is the pre-generated data. It was kinda tricky to properly write and access the right pixels of each generation of spheres, but I think it's working fine.

Rendering times begin to really slow down at more than 9 iterations, as I expected,  but it's the only solution I found since I only know how to render using distance estimation.
Also the only optimization I found so far, was to check DE for the spheres on either side of the fractal at the same time, taking advantage of the symmetry so I only have to track positions of half of the spheres. The test image was 12 iterations, so it scans of the positions of 8000+ spheres but does a DE combination of 16000+ that are finally shown (thanks to the optimization).

I attached the .frag, it's a modification of "DE-Raytracer-v0.9.1.frag", and my code is mostly on the "main()" section, and in the included DE function, off course.
I added some comments to the code, but it's a mess and I barely understand it myself  grin

Be sure to run it in continuous mode to make it work, and use preview modes if it's running too slow. I recommend lowering the value of OpenGL refresh rate on edit->preferences for faster pre-calculation.

Any other suggestions are welcome.



* dragondifstest.frag (17.3 KB - downloaded 555 times.)
« Last Edit: March 06, 2013, 01:03:53 AM by Kali » Logged

David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #14 on: March 06, 2013, 04:43:19 PM »

<snip?
ps; there is also a way to work this around *but* it seems to be absolutely complicated. Dave Makin made a very accurate 2d formula but I simply can not understand it at all! alien alien alien

The key with "my" method is that it is not KIFS, it's truly IFS - *the entire IFS tree* is traversed *per pixel* (and per ray position if in 3D to get DE values) so the entire tree is calculated only stopping going deeper on each path down the tree when a threshold scale factor is reached (for that path). I haven't actually written a 3D version using DE yet because I still haven't found a satisfactory "formula" for the DE when the transforms in the IFS are very different in scale (it's OK for 2D but so far from optimum I haven't even tried it for 3D yet).

For affine 3D IFS Hart's method is waaay better - DE is only needed for non-affine IFS - Hart's method again also does the entire tree per pixel but directly returns an intersectiion with the attractor or not - so no DE stepping required.
Logged

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

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
Pages: [1] 2   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
DE estimation - help needed Mandelbulb Implementation chaospro 3 1998 Last post April 19, 2010, 02:29:28 AM
by David Makin
Fractal animation needed Commission an Artist shufflelot 10 10072 Last post October 02, 2010, 08:49:38 PM
by Sockratease
DragonKIFS Images Showcase (Rate My Fractal) Kali 2 860 Last post October 15, 2012, 06:35:29 PM
by cKleinhuis
Bipolar coordinates look promising (new) Theories & Research Hiato 4 761 Last post August 24, 2014, 04:28:23 PM
by David Makin
help needed for introduction chaosTube - History cKleinhuis 4 1500 Last post January 24, 2013, 11:03:59 PM
by Madman

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.192 seconds with 24 queries. (Pretty URLs adds 0.011s, 2q)