Logo by Fiery - 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. April 20, 2024, 09:38:34 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: Another discontinous function  (Read 1517 times)
0 Members and 1 Guest are viewing this topic.
tryptophan
Safarist
******
Posts: 86


« on: May 09, 2013, 12:11:21 PM »

I've got another function that is pretty noisy. It makes some really cool shapes though and I was wondering if someone might have an idea how to make it more solid. Basically it's really noisy no matter what settings I set. Here's the code:

Code:
float DE(in vec3 p )
{
float d = 0;
float fat = Fatness;
orbitTrap = vec4(1000.0);

for( int i=0; i<Iterations;i++ )
{
p = abs(p);
float r2 = dot(p,p);
if (i <= ColorIterations) orbitTrap = min( orbitTrap, vec4(abs(p)*12,r2) );
               
float k = max(Scale/r2,0.1);
p     *= k;
fat *= k;
p *= Julia+1.0;
p += Offset;
p *= rot1;
                        d = 0.25*abs(p.y)/fat;
                        return d;
                }

the settings Scale = 1, Fatness = 1, and Offset -1.08,-1.2,-0.9 with the rest at 0 are a pretty cool zone. If anyone has and idea on how to reduce the noise that would be amazing.

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


formerly known as 'Trifox'


WWW
« Reply #1 on: May 09, 2013, 12:35:56 PM »

an example image huh?
Logged

---

divide and conquer - iterate and rule - chaos is No random!
eiffie
Guest
« Reply #2 on: May 09, 2013, 05:42:58 PM »

yikes it doesn't make sense (perhaps you copied it wrong??)
It bails out and returns d on the first loop. I am guessing there was a } after /fat;

In that case the offending line is z*=Julia+1.0; (not sure what you were trying for there?)
Logged
tryptophan
Safarist
******
Posts: 86


« Reply #3 on: May 09, 2013, 08:04:18 PM »

Sorry my bad I did copy it wrong. I have what I'm calling Input(loop) and Output (distance calc) modes/switches so I missed a bracket. Yeah the so called julia doesn't do much in that mode in another though with small values it has a flowering effect. Just rendering some images for you guys to check out I've come to realize its my DE engine. I've just started writing my own ray marcher the other day. (I have to admit hacked together by referring to marchers written by, Syntopia, IQ, Effie your global Illumination is the next thing I'm going to look at) but I have written every line and have implemented a few of my own ideas, mostly for coloring, and lighting. Once I get it a little further along I'll make a Fragmentarium version and post it in a new thread.

The original formula I got from an IQ post on ShaderToy called Apollonian. I then made 3 different iteration modes and 6 different output modes which includes the original. All this gave me an idea this morning to make a system for combining formulas together outside of the shader which I think will increase the shaders speed, but that is for a later date. I'll post the full formula and a few images:

Code:
float DE(in vec3 p )
{
float d = 0;
float fat = Fatness;
orbitTrap = vec4(1000.0);

if (InputMode == 0)
{
for( int i=0; i<Iterations;i++ )
{
p = -1.0 + 2.0*fract(0.5*p+0.5);

float r2 = dot(p,p);
if (i <= ColorIterations) orbitTrap = min( orbitTrap, vec4(abs(p)*12,r2) );

float k = max(Scale/r2,0.1);
p     *= k;
fat *= k;
p *= Julia+1.0;
p += Offset;
p *= rot1;
}
}

else if (InputMode == 1)
{
for( int i=0; i<Iterations;i++ )
{
p = -1.0 + 2.0*fract(0.5*p+0.5);
if (p.x+p.y < 0.0) p.xy = -p.xy;
if (p.x+p.z < 0.0) p.xz = -p.xz;
if (p.y+p.z < 0.0) p.yz = -p.yz;
float r2 = dot(p,p);
if (i <= ColorIterations) orbitTrap = min( orbitTrap, vec4(abs(p)*12,r2) );
                
float k = max(Scale/r2,0.1);
p     *= k;
fat *= k;
p *= Julia+1.0;
p += Offset;
p *= rot1;
}
}

else if (InputMode == 2)
{
for( int i=0; i<Iterations;i++ )
{
p = abs(p);
float r2 = dot(p,p);
if (i <= ColorIterations) orbitTrap = min( orbitTrap, vec4(abs(p)*12,r2) );
                
float k = max(Scale/r2,0.1);
p     *= k;
fat *= k;
p *= Julia+1.0;
p += Offset;
p *= rot1;
}
}

else
{
for( int i=0; i<Iterations;i++ )
{
p = abs(Tile.xyz-mod(p,2.0*Tile.xyz));
float r2 = dot(p,p);
if (i <= ColorIterations) orbitTrap = min( orbitTrap, vec4(abs(p)*12,r2) );
                
float k = max(Scale/r2,0.1);
p     *= k;
fat *= k;
p *= Julia+1.0;
p += Offset;
p *= rot1;
}
}

if (OutputMode == 0)
{
d = 0.25*length(p.xyz)/fat;
}
else if (OutputMode == 1)
{
d = 0.25*abs(p.y)/fat;///length(Offset);
}
else if (OutputMode == 2)
{
d = min(0.25*length(p.xyz),sdBox(normalize(p*CubeJulia+CubeOffset),CubeScale))/fat;
}
else if (OutputMode == 3)
{
d = min(0.25*abs(p.y),sdBox(normalize(p*CubeJulia+CubeOffset),CubeScale))/fat;
}
else if (OutputMode == 4)
{
d =max(0.25*length(p.xyz),sdBox(normalize(p*CubeJulia+CubeOffset),CubeScale))/fat;
}
else if (OutputMode == 5)
{
d = max(0.25*abs(p.y),sdBox(normalize(p*CubeJulia+CubeOffset),CubeScale))/fat;
}


orbitTrap = orbitTrap * ColorScale + ColorOffset;

return d;
}

The first one has the noise I was talking about as well as another on the next post.


* Spherical Tests_0000_Layer 4.jpg (89.4 KB, 634x356 - viewed 250 times.)

* Spherical Tests_0001_Layer 3.jpg (47.09 KB, 634x356 - viewed 284 times.)

* Spherical Tests_0002_Layer 5.jpg (77.16 KB, 634x356 - viewed 269 times.)
« Last Edit: May 09, 2013, 08:06:54 PM by tryptophan » Logged
tryptophan
Safarist
******
Posts: 86


« Reply #4 on: May 09, 2013, 08:08:29 PM »

here a couple more


* Spherical Tests_0003_Layer 2.jpg (61.12 KB, 634x356 - viewed 269 times.)

* Spherical Tests_0004_Layer 1.jpg (104.44 KB, 634x356 - viewed 276 times.)

* Spherical Tests_0005_Layer 0.jpg (82.88 KB, 634x356 - viewed 268 times.)
Logged
KRAFTWERK
Global Moderator
Fractal Senior
******
Posts: 1439


Virtual Surreality


WWW
« Reply #5 on: May 09, 2013, 08:42:11 PM »

I like some of those images, interesting!
Logged

eiffie
Guest
« Reply #6 on: May 09, 2013, 11:18:48 PM »

OK if julia is a vector (i assume) then you need to multiply "fat" by the larger of julia.x,y or z.

When you multiply "p" by something you also need to multiply your variable "fat" by the same but since "fat" is just a scalar you need to take the worst case.

There is a more accurate way but I really can't explain it - look at IQ's ellipse sample on ShaderToy. https://www.shadertoy.com/view/MdfGWn
Logged
tryptophan
Safarist
******
Posts: 86


« Reply #7 on: May 09, 2013, 11:40:53 PM »

Thanks Effie that makes total sense. I figured I would have to do something to balance the formula. I just wasn't sure what. I've just checked out IQ's maintain a constant distance to boundary and that looks like it would be really helpful. Thanks again for the help.

Ps next time I'll post the uniform declarations as well so it obvious what is a vector or scalar. - julia is a vector in the above example

cheers
Keith
Logged
tryptophan
Safarist
******
Posts: 86


« Reply #8 on: May 10, 2013, 01:02:21 AM »

Quote
I like some of those images, interesting!

Thanks Kraftwerk I thought so also.
Logged
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #9 on: May 10, 2013, 03:59:01 AM »

lol,  @tryptophan, stop coding, start produciiiiiiiiiiiiiiiiiiing!
Logged

---

divide and conquer - iterate and rule - chaos is No random!
tryptophan
Safarist
******
Posts: 86


« Reply #10 on: May 10, 2013, 04:03:01 AM »

I know I know but there are just so many combinations!!!  cheesy . Actually I have been though but just short loops for live visuals.

Logged
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
from image to function General Discussion A.Real 13 5083 Last post November 07, 2006, 07:26:14 AM
by lycium
Search function Discuss Fractal Forums cbuchner1 4 954 Last post December 29, 2009, 11:21:12 PM
by Nahee_Enterprises
Any function you like.... Theory David Makin 5 2018 Last post December 18, 2009, 11:16:48 PM
by David Makin
Function of Reality Images Showcase (Rate My Fractal) alexl 1 1963 Last post April 03, 2012, 04:32:51 AM
by weavers
Revolve a 2D XY function around Z? Fragmentarium Patryk Kizny 2 816 Last post November 14, 2015, 07:01:39 PM
by Patryk Kizny

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