Logo by rathinagiri - 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: Did you know ? you can use LaTex inside Postings on fractalforums.com!
 
*
Welcome, Guest. Please login or register. April 24, 2024, 05:41:24 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 3 ... 8   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: Custom formulas & transforms - WIP & discuss  (Read 16713 times)
0 Members and 1 Guest are viewing this topic.
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« on: February 05, 2011, 07:04:14 PM »

Hi all. I have looked at the formulas of MB3D, and I have "studied" the simplest ones. So I understood the basic "constants" and I was able to write some custom transforms angel angel angel

I opened this thread to ask Jesse the permission to share the formulas with everybody. Please give it to me...  cry

(And I will be happy to know some more details to write other transforms please wink)

Luca.  cheesy
« Last Edit: February 07, 2011, 12:38:59 PM by DarkBeam » Logged

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


Fragments of the fractal -like the tip of it


« Reply #1 on: February 05, 2011, 07:15:49 PM »

Here is an example; Integer Power before and after an "Inverse cylindrical" transform.  grin


* inversecy.jpg (161.66 KB, 725x1306 - viewed 752 times.)
Logged

No sweat, guardian of wisdom!
Jesse
Download Section
Fractal Schemer
*
Posts: 1013


« Reply #2 on: February 05, 2011, 11:20:39 PM »

Already answered your private message, of course you can publish selfmade formulas, thats great!

Here are some additional infos that may help a bit:

Code:
  TIteration3Dext = packed record
    J4,Rold,RStopD,x,y,z,w: Double;   // use with neg indizes before C1
    C1, C2, C3: Double;     //  
    J1, J2, J3: Double;     //+24   these are the constants for adding. (x0, y0, z0) or (Cx, Cy, Cz).  w0 is J4 (-56)
    PVar:       Pointer;    //+48   the actual formulas adress of constants and vars
    SmoothItD:  Single;     //+52
    Rout:       Double;     //+56   the square of the vector length, can be used as input
    ItResultI:  Integer;    //+64
    maxIt:      Integer;    //+68
    RStop:      Single;     //+72
    nHybrid:    array[0..5] of Integer;  //+76 Hybrid counts or single weights in interpolhybrid
    fHPVar:     array[0..5] of Pointer;  //+100 pointer to constants+vars, PVars-8=0.5, dOption values below -8
    fHybrid:    array[0..5] of ThybridIteration2; //+124   adresses of formulas
    CalcSIT:    LongBool;   //+148
    DoJulia:    LongBool;   //+152
    LNRStop:    Single;     //+156
    DEoption:   Integer;    //+160
    fHln:       array[0..5] of Single;  //+164  for SmoothIts
    iRepeatFrom: Integer;   //+188
    OTrap:      Double;     //+192
    VaryScale:  Double;     //+200    to use in vary by its
    bFirstIt:   Integer;    //+208    used also as iteration count, is set to 0 on it-start
    bTmp:       Integer;    //+212    tmpBuf, free of use.
    Dfree1:     Double;     //+216
    Dfree2:     Double;     //+224
    Deriv1:     Double;     //+232    for 4D first deriv or as full derivs
    Deriv2:     Double;     //+240
    Deriv3:     Double;     //+248
    SMatrix4:   TSMatrix4;  //+256
  end;

x,y,z,w is also [eax],[edx],[ecx],[ecx+8]

A common outline of a formula:

    push  ebp
    mov   ebp, esp
    push  esi
    push  edi
    mov   esi, [ebp + 8]    //PIteration3D = @TIteration3Dext.C1  
    mov   edi, [esi + 48]   //PAligned16, constants with index 0 and increasing, -8 is always double=0.5, user variables are below -8
  //  fld   qword [ecx + 8]
    fld   qword [ecx]
    fld   qword [edx]
    fld   qword [eax]        //x,y,z(,w)
...
    fadd  qword [esi + 24]  // add Cx
    fstp  qword [eax]
    fadd  qword [esi + 32]  // add Cy
    fstp  qword [edx]
    fadd  qword [esi + 40]  // add Cz
    fstp  qword [ecx]
 //   fadd  qword [esi - 56]  // add Cw
 //   fstp  qword [ecx + 8]
    pop   edi
    pop   esi
    pop   ebp
    ret   $0008

Here is the struct for C programmers and some additional infos from marius,
and the common variables are named like they are used in the formula descriptions:

Code:
__attribute__((packed)) struct TIteration3Dext {
double Cw,Rold,RStopD,x,y,z,w; // use with neg indizes before C1. w is also used for 3d ifs and abox analytic DE
double Px, Py, Pz;             //      actual position, never change these!  Can be used as input.
double Cx, Cy, Cz;             //+24   these are the constants for adding. Pxyz or the julia seed.  Cw is @-56 (begin of struct)
void*  PVar;                   //+48   the actual formulas adress of constants and vars, constants at offset 0 increasing, user vars below -8
float  SmoothItD;              //+52
double Rout;                   //+56   the square of the vector length, can be used as input
int    ItResultI;              //+64
int    maxIt;                  //+68
float  RStop;                  //+72
int    nHybrid[6];             //+76   all formulas iteration counts or single weights in interpol-hybrid
void*  fHPVar[6];              //+100  all formulas pointer to constants+vars, PVars-8=0.5, use PVar for the actual formula
void*  fHybrid[6];             //+124  the formulas adresses
int    CalcSIT;                //+148
int    DoJulia;                //+152
float  LNRStop;                //+156
int    DEoption;               //+160
float  fHln[6];                //+164  for SmoothIts
int    iRepeatFrom;            //+188
double OTrap;                  //+192
double VaryScale;              //+200  to use in vary by its
int    bFirstIt;               //+208  used also as iteration count, is set to 0 on it-start
int    bTmp;                   //+212  tmpBuf, free of use.
double Dfree1;                 //+216
double Dfree2;                 //+224
double Deriv1;                 //+232  for 4D first deriv or as full derivs
double Deriv2;                 //+240
double Deriv3;                 //+248
float  SMatrix4[4][4];         //+256  for 4d rotation, used like most other values only by the programs iteration loop procedure
};

// fastcall is not quite delphi fastcall.
// first two args are ok, third is in ecx in delphi, on stack here.
void __attribute__((fastcall)) formula(
             double* x,      // [eax]
             double* y,      // [edx]
             double* arg,    // [ebp+8], points to TIteration3Dext.C1
             void* dummy     // so we end w/ ret 8 as delphi expects
             ) {
  // Compute ptr to proper start of TIteration3Dext struct.
  struct TIteration3Dext* cfg = (struct TIteration3Dext*)(arg-7);

  // Read / write some fields as demonstration.. not a real formula ;-)
  double r = cfg->x + cfg->y - cfg->z * cfg->w;
  cfg->Deriv1 = r;
}

compile with 'gcc -c -Os -m32'.

Objdump -D can be used to show the generated code.

Be aware to not use absolute addresses or compiler generated callings to functions that don't exists in m3d.
« Last Edit: September 23, 2011, 09:33:57 PM by Jesse, Reason: added infos for C programmers » Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #3 on: February 06, 2011, 10:38:43 AM »

 afro Wow very cool... I am still trying to optimize formulas at my best, it is hard to do, I hope to be done soon evil
Logged

No sweat, guardian of wisdom!
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #4 on: February 06, 2011, 11:08:36 AM »

crazy stuff, hand coded assembla formulas!
Logged

---

divide and conquer - iterate and rule - chaos is No random!
David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #5 on: February 06, 2011, 01:06:01 PM »

crazy stuff, hand coded assembla formulas!

I beg to differ, as far as CPU/FPU code goes then writing the guts of fractal code in any higher language is completely nuts if you are capable of writing it in native code and have the facility to do so - in the past you would get a absolute minimum 10 to 20 times speed up as compared to even an optimising compiler and even now you'll get a 2 to 5 times speed increase (that's assuming you know what you're doing with respect to pipelines, caching, free cycles and stalling etc.).
Of course GPU code is a slightly different matter !
« Last Edit: February 06, 2011, 01:08:08 PM by David Makin » Logged

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

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #6 on: February 06, 2011, 01:47:19 PM »

Please please try those. embarrass

Those are simple "basic" transforms, unoptimized for now (optimize machine code is expert stuff! hurt )
There is a "gnarl2D" transform that is very slow and don't work well with all formulas, but somebody can suggest me how to fix... cheesy

* custom-formulas.zip (2.6 KB - downloaded 395 times.)
Logged

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


Fragments of the fractal -like the tip of it


« Reply #7 on: February 06, 2011, 05:45:26 PM »

A quick set of log type transforms, thanks to this site; http://webster.cs.ucr.edu/AoA/Windows/HTML/RealArithmetica2.html

A quick test;

Mandelbulb3Dv16{
M.....S....O/...w....2.....ZGT/tvZ1wz8GogQwZYr1EceXg9OUXbwX.bczPYdIwzuYOfjjr.nzD
................................NjiugQrlqz1........Y./..................y.2.....
................/ME//....6kq2...b/....E2.....M6N4krMKaqD/..........c./...wX....E
./kX0LDD..../..........wz.............................................sD...../..
.w1...sDJUCstBaZdx1..........U52is.3qHdjuA80MK.dBu107jAY7VVMzc5F6Y4LL6qDWeqgXcMd
BuHA4ncOQRVMzmqA5xMGM6qD......oA......................sD..kz0...................
.............................UJRR4.uppN.sNLb/UkRR4.arpN.cULb/U9SR4..............
...........................U..6.P....M4...EB....W....61....F....8/...I1....UJl12
...U.iVFwxDE./ozPM2Tzz7lz16.mc..zXCc.El18XGQeGyDjvIRhrVAkz1............28.kFrA0.
FWb96aAIVzvh1se7Umvxz0........../6U0.wzzz1................................E.0c..
zzzz.................................2U.8.kzzzD.................................
/6U0.wzzz1...................................2CcN/UvNP6.eeWCNq0.yRii.EJJUk1f..XR
S1.mx3CcN/UvNP6.QsLsUa3.ibhV..bTV1OK.sSq40.ly3CcN/UvNP6.MwLsUa3.ibhV.kqTV1OK.sSq
40.kz3CcN/UvNP6...EsUa3.eeWCNq0.IJ36wk8.wyLsUa3.................................
E....6...../....I....6....kL/pKMuZaPb7oPs/UFH/........................k/..U/4MU/
4M.................0./........yDOaNaNaNa7z1.....................................
................................................................................
.....................2.....3.........w3HjRaK....................................
..............................0E................................................
................................................................................
................................}

 grin grin grin

* log xyz.zip (0.77 KB - downloaded 284 times.)
Logged

No sweat, guardian of wisdom!
bib
Global Moderator
Fractal Senior
******
Posts: 2070


At the borders...


100008697663777 @bib993
WWW
« Reply #8 on: February 06, 2011, 05:57:57 PM »

Welcome to FF Luca wink
Logged

Between order and disorder reigns a delicious moment. (Paul Valéry)
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #9 on: February 06, 2011, 06:08:52 PM »

Welcome to FF Luca wink
embarrass Thanks a lot... I am a little devil angel
Logged

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


Fragments of the fractal -like the tip of it


« Reply #10 on: February 06, 2011, 06:28:09 PM »

 cheesy Fantastic!!! This is a 3D gnarl!!! Simply used a 2D gnarl transform (alone) plus a flipxz... Check by yourself!!!

Mandelbulb3Dv16{
M....kf....j0...w....2...............1.......s1E................................
................................vFVf53iSoy1........A./..................y.2.....
................/ME//....6U6....N7....E2......Pht/mw1CuD/..........c./...w1.....
./UaNadD..../..........wz.............................................sD...../..
.w1...sDYsAIxzzzjz1..........WAbUdisqcljTcFzUvMS3t97C1JzzzzvzUNehUisqcljMaO9c9iB
Ow1mQ0auWPX4zU2bVezzzzyD......2F......................sD..kz0...................
.............................UJRR4.uppN.sNLb/UkRR4.arpN.cULb/U9SR4..............
...........................U..6.P....M4...EB....W....61....F....8/...I1....UJl12
...U.iVFwxDE./ozPM2Tzz7lz16.mc..zXCc.El18XGQeGyDjvIRhrVAkz1............28.kFrA0.
FWb96aAIVzvh1se7Umvxz0........../6U0.wzzz1................................E.0c..
zzzz.................................2U.8.kzzzD.................................
/6U0.wzzz1...................................2CcN/UvNP6.eeWCNq0.yRii.EJJUk1f..XR
S1.mx3CcN/UvNP6.QsLsUa3.ibhV..bTV1OK.sSq40.ly3CcN/UvNP6.MwLsUa3.ibhV.kqTV1OK.sSq
40.kz3CcN/UvNP6...EsUa3.eeWCNq0.IJ36wk8.wyLsUa3.................................
E....6....E.....I....I....kLbtKMmlaA2/..rJaQ................................A...
...................wzcNaNaNaNavDOaNaNaNaty1........0./.........E................
................................................................................
.....................2.....3.........wZFgZ4QMd3.mZqMVl4.g/......................
4MU/.........................E1E..................cJ.1.......U.E..........2.....
................................................................................
................................}

 shocked

But it seems more a vine one smiley

This example uses 4D rotation


Mandelbulb3Dv16{
M....kf....j0...w....2....UbODfMigY6.ve2auAOOP1ErqG5MJj0vzv7E9KNNph1.lHhbJALKm/k
................................vFVf53iSoy1........A./..................y.2.....
................/ME//....6EW....76....E2......Pht/mw1CuD/..........c./...w1/....
./kX0LDD..../..........wz.............................................sD...../..
.w1...sD/Zh4j8Hcaz1.UqeAEZc2zYonlUV0UOyDAuRcysmzTzfkaqEWp.etzC8.SBGz..yDTfHoBtmz
TznktH0E52etzOJrpmFezzxj......YO......................sD..kz0...................
.............................UJRR4.uppN.sNLb/UkRR4.arpN.cULb/U9SR4..............
...........................U..6.P....M4...EB....W....61....F....8/...I1....UJl12
...U.iVFwxDE./ozPM2Tzz7lz16.mc..zXCc.El18XGQeGyDjvIRhrVAkz1............28.kFrA0.
FWb96aAIVzvh1se7Umvxz0........../6U0.wzzz1................................E.0c..
zzzz.................................2U.8.kzzzD.................................
/6U0.wzzz1...................................2CcN/UvNP6.eeWCNq0.yRii.EJJUk1f..XR
S1.mx3CcN/UvNP6.QsLsUa3.ibhV..bTV1OK.sSq40.ly3CcN/UvNP6.MwLsUa3.ibhV.kqTV1OK.sSq
40.kz3CcN/UvNP6...EsUa3.eeWCNq0.IJ36wk8.wyLsUa3.................................
E....A....E.....I....I....kLbtKMmlaA2/..rJaQ................................A...
...................wzcNaNaNaNavDOaNaNaNaty1........0./.........E................
................................................................................
.....................2.....3.........wZFgZ4QMd3.NxaP7FrQ........................
.MU/.........................E1E..................cJ.1.......U.E..........2.....
................................................................................
................................/....E/...U/....T7pPo34RZF1N..kN.wqR............
...........1Ak.1Ak........................................................2.....
...../.........E................................................................
............................................}

EDIT CHECK OUT CORRECTED GNARL2D POST DOWN


* 3D gnarl.jpg (214.88 KB, 859x870 - viewed 706 times.)
« Last Edit: February 06, 2011, 11:52:29 PM by DarkBeam » Logged

No sweat, guardian of wisdom!
n8iveattitude1
Forums Freshman
**
Posts: 10


« Reply #11 on: February 06, 2011, 08:48:35 PM »

i tried ABsY and gnarl2d wink

Mandelbulb3Dv16{
M.....S...kX/...61.........X7wC3HGrezcdazGQmXV/E3d0z0WBvxy1XF.r9vzetzctSaA0yk3xD
................................TJYt2GuDl.2........Y./..................y.2.....
................/M.//....6ED/...H1....E......Mb52a7KZ1nD/..........c./...w1.BnAH
z.....kD..../2UaNaNaNaNiz.............................................sD...../..
.w1...sDi.J5EODtbwHdCg/XqHy7zqnDEV/f3d7jJmc6xj9tUwncfUzzvGC6z27.5xzoZTmjpi8NhITt
Uwn0Zd1ApLC6zolqgHF4YTmD......Y3......................sD.2kz0...................
.............................UJRd..upZ0.sNL8.UkRd..arZ0.cUL8.U9Sd...............
................a..........U..6.k....E4....C....J0...c1...k1....S....Aoz..EpIF1A
...U.WLS1KoiuKABHWMSbY9hc06.2cE.8LQj.MxuvBTuCfuDUYwlbsII5.AEJzHmWnv4.1EBI.UVcp2.
.....................EWfzHx6d2yD2I13.YrVp0.e/0biMaOyzcisP8OPAXzD.ezYfTLkRzH.Gc..
mcV0.MxuvBTuCfujKjySnbiney9..........EUA8ojH9l3.c.LWmfeBhzfVVmlUaotzzuCDd58g6zzD
Y6W0xvoGQ/kCaWctpJKwzW35PpHERyzjPD7Kl3Dkzz1..UeX80ksQjB.Sm.V8K7.eWel.kK4TRY9.29d
D0U3aEede0.cU08.UnHVyV5.Ma8e.6cHT/o6..8cU0.AWFvcD0kYJu8.daKQmh5.U08c.sFQ9q6Z.EtY
i0UXsFtXy/EsV5C....cU08.zz/cU08.yz1cU08.xz3cU08.................................
E....A....E/....I....c....kIdJaQkZaPnhKOn.UQ..............................U/4MU/
4M...................pAnAnAnAnyD........kz1........wz...........................
................................................................................
.....................2.....3.........wJEWBLK.UKNmZqMVl4.g/......................
6....MU/4MU/4................E0k........Y.2........3./..........................
................................................................................
................................/....E/...E/....TRaPV75PmE2.gFKOiRKA............
.................MU/4MU/........nAnAnAnAHzXaNaNaNaNizcNaNaNaNavD........E.2.....
...2./..........................................................................
............................................}
Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #12 on: February 06, 2011, 09:42:39 PM »

Images please... grin

Stay tuned I am trying to optimize toSpherical and I need some help smiley
Logged

No sweat, guardian of wisdom!
Madman
Fractal Molossus
**
Posts: 678



« Reply #13 on: February 06, 2011, 10:30:47 PM »

Nice additions, Darkbeam. This is a picture using your AbsX and invcylindrical

Logged

All I want is a warm bed, a kind word and unlimited power (Ashleigh Brilliant)
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #14 on: February 06, 2011, 11:40:07 PM »

Oh no sorry sorry! I mistaken in coding Gnarl2D, the last opcode is wrong. This is the correct version (that works perfectly as is as a standalone formula. Previous one was buggy!)

Code:
[OPTIONS]
.Version = 2
.DEoption = -1
.Double Strength = 1.03
.Double X step = 0.1
.Double Y step = 0.1
.Double Alpha = 3.0
.Double Beta = 2.0

[CODE]
558BEC568B75088B7630DD02DD46D0DEC9D9FEDD02DEC1DD46D8DEC9D9FEDD02
DEC1D9FEDD46E8DEC9D9E0DD00DEC1DD46F0DEC9DD00DD46D0DEC9D9FEDD00DE
C1DD46D8DEC9D9FEDD00DEC1D9FEDD46E0DEC9D9E0DD02DEC1DD46F0DEC9DD1A
DD185E5DC20800
[END]


Description:

Gnarl deformation in 2D (from Mark Townsend) - variation with step X & Y
Gnarl formula gives strange "smoke-like" shapes.
Formula by Luca GN 2011
TIPS
The formula works with all formulas including IFS ones and can be used alone
Handle with care. This transform uses massively sin - it is slow and may be fuzzy
Big values for alpha and beta perturb even more. Be very careful with the strength...

x' = (x - stepX sin(y + sin( a (y + sin (b y )))) * Strength
y' = (y - stepY sin(x + sin( a (x + sin (b x )))) * Strength
z unchanged
[/code]
« Last Edit: February 06, 2011, 11:42:56 PM by DarkBeam » Logged

No sweat, guardian of wisdom!
Pages: [1] 2 3 ... 8   Go Down
  Print  
 
Jump to:  


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.208 seconds with 25 queries. (Pretty URLs adds 0.008s, 2q)