• August 02, 2021, 08:00:40 AM

### Author Topic:  Converting UF formula to GLSL fragment  (Read 179 times)

0 Members and 1 Guest are viewing this topic.

#### 3DickUlus

• Posts: 2348
##### Converting UF formula to GLSL fragment
« on: July 18, 2021, 07:56:15 AM »
You can find the original UF code attached here Unveiling the Fractal Structure of Julia Sets with Lagrangian Descriptors,  my attempted conversion to fragment code is attached at the bottom of this post.

This is the first incarnation in GLSL for Fragmentarium, the images are each orbit function for Mandel and Julia sets there are also 11 Post iteration coloring functions.

Thanks very much go to Alef for sharing his code  I'm sure I've got a few things wrong in this script, corrections and contributions are welcomed

« Last Edit: Today at 01:40:28 AM by 3DickUlus »

#### Alef

• Fractal Furball
• Posts: 248
• a catalisator / z=z*sinh(z)-c^2
##### Re: Converting UF formula to GLSL fragment
« Reply #1 on: July 18, 2021, 11:29:09 PM »
At the first sign conversion of code seems to be correct. There is slight difficulty that some of that was taken from code which was Ultra Fractal implementation of a code originaly writen in Delphi Pascal with float numbers. But these orbits are complex unlike orbit traps, and DLD requires complex imput.

Lots of these things were taken from this file shared by Ed Algra in mailinglist. I think there still could be some usefull pieces of a code.
a catalisator / z=z*sinh(z)-c2

#### 3DickUlus

• Posts: 2348
##### Re: Converting UF formula to GLSL fragment
« Reply #2 on: July 19, 2021, 12:34:30 AM »
WOW!  there is a lot to explore in this frag. Will have a look at the code by Ed Algra, assuming (hoping) it's public domain? Should give some credit to him and thanks

Have been adding stuff and refining things, this is one of the best 2D fragments I've played with in a long time... just can't stop twiddling... The Possibilities Are Infinite!
Will update the frag in OP soon.
Attached image is my butchery of 'Ducks' fractal by Samuel Monnier ... based on ducks more like platypus

#### Alef

• Fractal Furball
• Posts: 248
• a catalisator / z=z*sinh(z)-c^2
##### Re: Converting UF formula to GLSL fragment
« Reply #3 on: July 19, 2021, 01:31:49 AM »
I have no idea about it's status. Ultimately it is taken from the source codes of Fractal Explorer 2.02, which were sold untill the authors dissapeared from internet alltogether.
Quote
; based on Fractal Explorer filter algorithms
; by Arthur Sirotinsky and Olga Federenko
; adapted for UF by Ed Algra - Oct.08
With file being modified on 6 aprill 2012 y. Still some ideas was pretty usefull.

#### 3DickUlus

• Posts: 2348
##### Re: Converting UF formula to GLSL fragment
« Reply #4 on: July 19, 2021, 01:56:20 AM »
At the first sign conversion of code seems to be correct.
ok    some options make 32bit float limits show as garbage lines in the images but only when using certain combinations.
There is slight difficulty that some of that was taken from code which was Ultra Fractal implementation of a code originaly writen in Delphi Pascal with float numbers.
the hard part is getting the math into code form, doesn't really matter the first language as long as the author got it right it should not be a problem to propagte to any language.
But these orbits are complex unlike orbit traps, and DLD requires complex imput.
Working through it... thinking of a specialized color options fragment that can be included and used by any of the existing frags.
Lots of these things were taken from this file shared by Ed Algra in mailinglist. I think there still could be some usefull pieces of a code.
Fractal Explorer Coloring.ucl is 3182 lines of code!  this could take a while... maybe should just write a parser that converts .ucl to .frag  will have to grok lexx docs.

#### Alef

• Fractal Furball
• Posts: 248
• a catalisator / z=z*sinh(z)-c^2
##### Re: Converting UF formula to GLSL fragment
« Reply #5 on: July 19, 2021, 01:47:38 PM »
I think it is mostly usefull for formula coders. Most of the color methods there is not worth but some stuff could be recycled in other formulas;)

float d = SquaredModulus ? sqr(mod(ztemp.x,ztemp.y)) : //cAbs(cSqr(ztemp));
Maybe modulus squared could be simplified. That would not result in any significant gain of speed (nowedays) but it calculates twice the same thing.  This operator could be kind of old tradition of times of MsDOS. I just looked at this as it could be misleading.
Quote
Ultra Fractal Help
|...| (modulus squared) operator
.....
To complicate matters even further, this operator doesn't even calculate the complex modulus, it calculates the square of the complex modulus, which is defined as:

|(a, b)| = a*a + b*b

The reason the squared modulus is returned instead of the modulus itself is that it's much faster to calculate the squared modulus (no square root operation is necessary).

To calculate the complex modulus, use the cabs function.

case 17: ztemp = vec2(sinh(ztemp)+1.0E-9);
This depends on does vec2 uses complex sinh function or not. Real sinh on two components could be less interesting as it is just a curve. In complex it is oscilating function.
Probably here it is two real sinh as I don't see a "thorns" as I got in Ultra Fractal.

Quote
4.7 The complex functions
Sinh(z):                      // -hiperbolic sinus
X_new := Sinh(X)*Cos(Y);                      // -it is not optimized formula
Y_new := Cosh(X)*Sin(Y);
I wanted to share help file of these complex fuctions somewhere ower fractalforums, could be usefull.

Programm Chaos pro have some auto coverter of UF code to it's own more C like. Chaos pro is freeware unlike Ultra Fractal. Maybe usefull for rendering but it's mostly 2D fractals. Probably parser would not be worth the effors;)

#### Alef

• Fractal Furball
• Posts: 248
• a catalisator / z=z*sinh(z)-c^2
##### Re: Converting UF formula to GLSL fragment
« Reply #6 on: July 19, 2021, 11:46:50 PM »
Nice. More is better, in one areas works one thing, and in another different.

#### 3DickUlus

• Posts: 2348
##### Re: Converting UF formula to GLSL fragment
« Reply #7 on: July 20, 2021, 04:02:43 AM »
re: modulus was just trying to figure out if UF uses the value returned by modulus then squares it or square the complex before modulus (both have interesting results) it is my understanding that complex modulus is == cAbs(complex).

the original UF code...
Code: [Select]
; core color algoritm starts here  float d =  |Ztemp|       ;modulus squared!now is an option for 2 versions in the GLSL frag
Code: [Select]
//  core color algoritm starts herefloat d = SquaredModulus ? sqr(mod(ztemp.x,ztemp.y)) :          // squared modulus using standard math functions                           cAbs(cSqr(ztemp));                   // modulus of squared using complex math functions...still just playing around with it to see what works in GLSL vs UF
edit: attached SquaredModulus =off and SquaredModulus=on

« Last Edit: July 20, 2021, 05:29:16 AM by 3DickUlus »

#### 3DickUlus

• Posts: 2348
##### Re: Converting UF formula to GLSL fragment
« Reply #8 on: July 20, 2021, 05:00:58 AM »
case 17: ztemp = vec2(sinh(ztemp)+1.0E-9); sinh(ztemp) performs the same operation on both parts of complex afaik

would this case 17: ztemp = vec2(sinh(ztemp.x), cosh(ztemp.y))+1.0E-9;  be what the UF to GLSL should look like

...inserted another case @18 ...
Code: [Select]
case 17: ztemp = vec2(sinh(ztemp)+1.0E-9); break; //   Hyperbolic Sincase 18: ztemp = vec2(sinh(ztemp.x), cosh(ztemp.y))+1.0E-9; // 3Dickulus...results attached
« Last Edit: July 20, 2021, 05:29:30 AM by 3DickUlus »

#### Alef

• Fractal Furball
• Posts: 248
• a catalisator / z=z*sinh(z)-c^2
##### Re: Converting UF formula to GLSL fragment
« Reply #9 on: July 20, 2021, 01:30:08 PM »
SquaredModulus-off.png in this example looks better. But maybe in zooms it could be different story, that should be tested. Maybe cAbs(cSqr(ztemp)) have some interesting patterns on spirals and with orbits. Mathematicaly sqr(mod(ztemp.x,ztemp.y)) must corsepond to UF |z| function. But this part of code is from Pauldebrot, I don't know what it is doeing;)

case 17: ztemp = vec2(sinh(ztemp)+1.0E-9); break; //   Hyperbolic Sin
Complex sinh seems to be OK as stalks are present just like in UF. Bu I don't have a metabrot formula so i tested on julia set.
Complex sinh - stalks,
vec2( Sinh(zx) , Sinh(zy)  ); -  nothing significant.
vec2( Sinh(zx) , Cosh(zy)  ); - have some patterns (in this level of zoom). In deeper zoom it looks like octopus tentacles what is pretty cool;)

Exact complex hyperbolic sin should be:
ztemp = vec2( Sinh(zx)*Cos(zy) ,   Cosh(zx)*Sin(zy)  );
« Last Edit: July 20, 2021, 08:20:22 PM by Alef »

#### Alef

• Fractal Furball
• Posts: 248
• a catalisator / z=z*sinh(z)-c^2
##### Re: Converting UF formula to GLSL fragment
« Reply #10 on: July 20, 2021, 09:08:53 PM »
Tested a bit in UltraFractal.

ztemp = vec2(sinh(ztemp.x), cosh(ztemp.y))+1.0E-9; // 3Dickulus
could be strenghtened by multiplication of some fractional number maybe say 0.3
ztemp = 0.3 * vec2(sinh(ztemp.x), cosh(ztemp.y))+1.0E-9;    // not shure if this code is OK
Then it have a lot more bubbles even where it previously didn't had. Maybe it could be parameterised but then eventualy formula would be owerloaded with paremeters

SquaredModulus-on.png  could be something of the absence of square function in modulus.
I tested on mandelbrot set as I don't have a metabrot. Modulus squared (UF function |z| ) and modulus of squared  ( cAbs(cSqr(ztemp)) in UF cabs(sqr(Ztemp))   )  did not show any real difference.

Modification with  modulus ( cabs()  ) just don't look as DLD suposedly should look (in paper), it have too mutch lines. But then it looks like SquaredModulus-on.png  Maybe it have some artistic use, not shure. On decreasing bailout it seems to normalise.
« Last Edit: July 20, 2021, 09:19:45 PM by Alef »

#### Alef

• Fractal Furball
• Posts: 248
• a catalisator / z=z*sinh(z)-c^2
##### Re: Converting UF formula to GLSL fragment
« Reply #11 on: July 21, 2021, 12:28:27 AM »
In experimenting with modulus I tried to calculate modulus squared by different means.
Changes are minimal. p=1 is more different, normal version and p=4 are more simmilar. Perhaps it needs larger power but for power 4 software have sqrt operator for square root and I don't want it slow down it too mutch. Mathematicaly all are OK. Called it "flavor" not to burden end users with algebra of Lp spaces

"Flavor p-norm"
IF (@pnorm == 0) ;// "Normal p=2"
d = sqr(real(Ztemp)) + sqr(imag(Ztemp))
ELSEIF (@pnorm == 1)  ;//  "Diamond p=1"
d = sqr( abs(real(Ztemp)) + abs(imag(Ztemp)))
ELSEIF (@pnorm == 2)  ;//  "Supercircle p=4"
d = sqrt( (real(Ztemp))^4 + (imag(Ztemp))^4 )
ENDIF

Pseudocode:
d = ztemp.x*ztemp.x + ztemp.y*ztemp.y
d = sqr( abs(ztemp.x) + abs(ztemp.y) )
d = sqrt( (ztemp.x)^4 + (ztemp.y)^4 )

This seems good enought so I added to UF "official" version.
« Last Edit: July 21, 2021, 12:56:19 AM by Alef »

#### 3DickUlus

• Posts: 2348
##### Re: Converting UF formula to GLSL fragment
« Reply #12 on: July 21, 2021, 07:01:56 AM »
Updated fragment code in OP    24 orbits

edit: works well with gimp gradient code by @patched just replace the return line with return ggr2glsl_color(sum).rgb;
« Last Edit: July 22, 2021, 06:57:28 AM by 3DickUlus, Reason: patched gradient code test »

#### Alef

• Fractal Furball
• Posts: 248
• a catalisator / z=z*sinh(z)-c^2
##### Re: Converting UF formula to GLSL fragment
« Reply #13 on: July 31, 2021, 10:41:07 AM »
I tested few more equations, well quite a bit I wrote down in countryside house relaxing from all the technologies exept electric kettle.

If you are interested
Code: [Select]
;more orbitsELSEIF (@orbits == 24);Azimuth SinZtemp= zx/( abs( sin(zy) ) + 1E-15) + flip(  zy/( abs( sin(zx) ) + 1E-15)  )ELSEIF (@orbits == 25);Cos RipplesZtemp= cos(zx)*zx + flip ( cos(zy)*zy )ELSEIF (@orbits == 26);Exponent StalksZtemp= 1.3^(-abs(zx))  + flip (  1.3^(-abs(zy))  )ELSEIF (@orbits == 27);Exponent RipplesZtemp= -1.2^(-abs(zx))  + flip (  -1.2^(-abs(zy))  )First is modification of secant sea aka thorn fractal. Must upload this to UF database...
Unfortunately these don't works on Ducks fractals as on quadratics. Maybe it needs special intended for Ducks. "Exponent Stalks" looks on julia set as in mandelbrot set, just that on this parameter it looks like fires.

#### 3DickUlus

• Posts: 2348
##### Re: Converting UF formula to GLSL fragment
« Reply #14 on: Today at 01:39:14 AM »
Updated frag in OP

### Similar Topics

###### Converting between Fractal eXtreme and Kalles Fraktaler palettes?

Started by FractalAlex on Kalles Fraktaler

3 Replies
238 Views
June 26, 2020, 01:22:28 AM
by panzerboy
###### Apollonian fragment

Started by CJR on Fragmentarium

5 Replies
501 Views
November 20, 2018, 05:44:06 PM
by Sabine62
###### Fragment repository

Started by CJR on Fragmentarium

6 Replies
510 Views
July 01, 2020, 07:20:41 AM
by 3DickUlus

Started by Sabine62 on Fragmentarium

5 Replies
398 Views
October 06, 2018, 09:15:58 AM
by Sabine62
###### Lagrangian Descriptors Fragment code

Started by 3DickUlus on Code Snippets (fragments)

10 Replies
747 Views
June 30, 2020, 01:32:59 AM
by 3DickUlus