Logo by Sockratease - 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. August 20, 2019, 08:27:33 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]   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: some code  (Read 2051 times)
0 Members and 1 Guest are viewing this topic.
Jesse
Download Section
Fractal Schemer
*
Posts: 1013


« on: August 13, 2011, 09:00:27 PM »

If someone is interested, here some m3d code:

Code:

function CalcDE(It3Dex: TPIteration3Dext; mctp: PMCTparameter): Double;
var dCT: TVec3D;
    Rtmp, RD1, RD2, RD3, Rst: Double;
    stmp, stmp2: Single;
    ftmp, itt, mi: Integer;
    CS, bIsC: LongBool;
begin
    if mctp.IsCustomDE then   //analytical DE method, based on one additional parameter
    with mctp^ do
    begin
      if DEoption = 20 then It3Dex.RStopD := msDEstop * StepWidth * 1.03;
      Result := mMandFunctionDE(@It3Dex.C1) * dDEscale;
    end
    else with It3Dex^ do
    begin                     //3d gradient
      CS := CalcSIT;
      mctp.mMandFunction(@C1); 
      CalcSIT := False;
      mi    := MaxIt;
      MaxIt := ItResultI;
      RStop := RStop * 8;
      Rtmp  := Rout;
      Rst   := mctp.mctDEoffset;
      mCopyVec(@dCT, @C1);
      mAddVecWeight(@C1, @mctp.Vgrads[2], Rst);
      mctp.mMandFunction(@C1);
      RD1 := Sqr(Rtmp - Rout);

      mCopyAddVecWeight(@C1, @dCT, @mctp.Vgrads[1], Rst);
      mctp.mMandFunction(@C1);
      RD2 := Sqr(Rtmp - Rout);

      mCopyAddVecWeight(@C1, @dCT, @mctp.Vgrads[0], Rst);
      mctp.mMandFunction(@C1);
      RD3 := Sqr(Rtmp - Rout);

      Result := Rtmp * Ln(Rtmp) * mctp.dDEscale / (Sqrt(RD1 + RD2 + RD3) + (Rst * 0.06));

      Rout := Rtmp;
      MaxIt := mi;
      RStop := mctp.dRStop;
      mCopyVec(@C1, @dCT);
      CalcSIT := CS;
    end;
    if Result < mctp.msDEstop * 0.25 then Result := mctp.msDEstop * 0.25;
    if mctp.FormulaType > 0 then   //DEcombinate, second formula
    begin
      itt := It3Dex.ItResultI;
      Rst := It3Dex.Otrap;
      stmp2 := It3Dex.SmoothItD;
      ftmp := mctp.FormulaType;
      mctp.FormulaType := 0;
      stmp := mctp.dDEscale;
      mctp.dDEscale := mctp.dDEscale2;
      bIsC := mctp.IsCustomDE;
      mctp.IsCustomDE := mctp.IsCustomDE2;
      It3Dex.nHybrid[0] := 999999;
      Rtmp := calcDE(It3Dex, mctp);
      case ftmp of
        1:  if Rtmp < Result then Result := Rtmp else begin It3Dex.ItResultI := itt; It3Dex.SmoothItD := stmp2; It3Dex.Otrap := Rst; end;
        2:  if Rtmp > Result then Result := Rtmp else begin It3Dex.ItResultI := itt; It3Dex.SmoothItD := stmp2; It3Dex.Otrap := Rst; end;
        3:  begin
              Result := Exp((Ln(Result) + Ln(Rtmp)) * 0.5);   
              It3Dex.ItResultI := Min(itt, It3Dex.ItResultI);
              It3Dex.SmoothItD := (It3Dex.SmoothItD + stmp2) * 0.5;
              It3Dex.Otrap := (It3Dex.Otrap + Rst) * 0.5;
            end;
      end;
      It3Dex.nHybrid[0] := 0;
      mctp.FormulaType := ftmp;
      mctp.dDEscale := stmp;
      mctp.IsCustomDE := bIsC;
    end;
end;


Raymarching part:


            RSFmul := 1;
            RLastStepWidth := dTmp * sZstepDiv;  //dTmp is the distance estimation, here on the first calculation point

            repeat

              if Iteration3Dext.ItResultI >= iMaxIt2 then // if inside while stepping, step back
              begin
                dT1 := -0.5 * RLastStepWidth;
                mZZ := mZZ + dT1;
                mAddVecWeight(@Iteration3Dext.C1, @VgradsFOV, dT1);
                msDEstop := DEstop * (1 + mZZ * mctDEstopFactor);
                dTmp := CalcDE(@Iteration3Dext, @MCTparas);
                RLastStepWidth := - dT1;
              end;

              if (Iteration3Dext.ItResultI < iMinIt) or
                ((Iteration3Dext.ItResultI < iMaxIt2) and (dTmp >= msDEstop)) then    //##### next step ######
              begin

                RLastDE := dTmp;

                dTmp := dTmp * sZstepDiv * RSFmul;
                dT1 := MaxCS(msDEstop, 0.4) * mctMH04ZSD;
                if dT1 < dTmp then
                begin
                  if not bFirstStep then StepCount := StepCount + dT1 / dTmp else StepCount := StepCount + Random;
                  dTmp := dT1;
                end
                else StepCount := StepCount + 1;
               
                if bFirstStep then
                begin
                  seed := 214013 * seed + 2531011;
                  bFirstStep := False;
                  dTmp := ((seed shr 16) and $7FFF) * 0.000030517578125 * dTmp;
                end;

                RLastStepWidth := dTmp;
                mZZ := mZZ + dTmp;
                mAddVecWeight(@Iteration3Dext.C1, @VgradsFOV, dTmp);
                msDEstop := DEstop * (1 + mZZ * mctDEstopFactor);

                dTmp := CalcDE(@Iteration3Dext, @MCTparas);

                if dTmp > RLastDE + RLastStepWidth then dTmp := RLastDE + RLastStepWidth;  //helps a little on julias etc

                if RLastDE > dTmp + s1em30 then  //a little down regulation
                begin
                  dT1 := RLastStepWidth / (RLastDE - dTmp);
                  if dT1 < 1 then
                    RSFmul := maxCS(0.5, dT1)
                  else
                    RSFmul := 1;
                end
                else RSFmul := 1;

              end
...
            until (mZZ > Zend) or PCalcThreadStats.pLBcalcStop^;

Logged
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #1 on: August 13, 2011, 10:13:41 PM »

lol,good ole turbopascal syntax...
Logged

---

divide and conquer - iterate and rule - chaos is No random!
Jesse
Download Section
Fractal Schemer
*
Posts: 1013


« Reply #2 on: August 13, 2011, 10:32:26 PM »

yeah, i miss these ol' times... had to program each line of the windows in dos turbo pascal by hand... ok i miss not that but surely something else  hrmm

(it is my youth, i think)

..the step between turbo pascal and delphi is deeper as it seems of course, it took a long time to get familiar with event triggered and thread using programming style.
« Last Edit: August 14, 2011, 12:25:53 AM by Jesse » Logged
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #3 on: August 14, 2011, 12:39:34 AM »

best thing is that "is equal" sign in tp is "=" whereas it is everywhere else "==", further on, the assignment via ":=" is more explicit - this way the single "=" gets freed for the if compare....
Logged

---

divide and conquer - iterate and rule - chaos is No random!
Syntopia
Fractal Molossus
**
Posts: 681



syntopiadk
WWW
« Reply #4 on: August 15, 2011, 08:47:19 AM »

Thanks for sharing, Jesse - I'll take a look and see if I can decipher some of your tricks :-)

And seeing the Pascal syntax brings back memories - I never really got into Delphi, but TurboPascal was a great environment.
Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #5 on: August 15, 2011, 09:59:12 AM »

Turbo Pascal? Nono, I only love C cheesy
Logged

No sweat, guardian of wisdom!
A Noniem
Alien
***
Posts: 38


« Reply #6 on: August 15, 2011, 02:46:32 PM »

Reminds me of my father who thinks pascal is still the best language for teaching purposes.
Logged
Jesse
Download Section
Fractal Schemer
*
Posts: 1013


« Reply #7 on: August 15, 2011, 10:27:15 PM »

I love pascal and pure assembler, no C or intels simd inline coding  angry

Of course, if i would be used to other languages, i would tell the opposite  wink
It is just to hard for me to change completely, just installed Visual C, how annoying  grin
Logged
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
the simpliest naive bruteforce code for mandelbulb Programming « 1 2 3 4 5 » ker2x 68 9943 Last post April 01, 2012, 02:57:39 PM
by David Makin
Break the code Fractal Humor KRAFTWERK 11 6042 Last post November 25, 2011, 05:27:04 PM
by cKleinhuis
simple code for mandelbox Programming Owl 10 6102 Last post July 28, 2016, 12:57:34 PM
by faxingberlin
Help ! what is this code ? Programming ker2x 2 217 Last post April 16, 2014, 08:50:29 PM
by ker2x
How to convert MB3D parameter code to people can read like flame code? Mandelbulb 3d fengda2870 4 350 Last post December 30, 2016, 03:32:42 PM
by lycium

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.168 seconds with 28 queries. (Pretty URLs adds 0.019s, 2q)