Logo by DarkBeam - 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: Visit us on facebook
 
*
Welcome, Guest. Please login or register. November 12, 2019, 11:27:09 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: Boolean operation on a point (vector)?  (Read 789 times)
0 Members and 1 Guest are viewing this topic.
tryptophan
Safarist
******
Posts: 86


« on: October 26, 2013, 10:44:43 PM »

I'm wondering if there is way to do an boolean intersection on a formula using the point position (vector) rather than the distance (float). Basically I would like to cut just a sphere out of a formula before the distance estimate is calculated.

thanks
Keith
« Last Edit: October 29, 2013, 05:44:31 AM by Nahee_Enterprises » Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #1 on: October 27, 2013, 10:35:07 AM »

I think you are mixing what cannot be mixed!
A "sphere" is defined by the distance of its surface because it is a "surface" (lol)
How can you ever "subtract" this from a "formula"...  and what you mean?

smiley
Logged

No sweat, guardian of wisdom!
tryptophan
Safarist
******
Posts: 86


« Reply #2 on: October 27, 2013, 06:00:34 PM »

Yeah I thought I was approaching it from the wrong angle. Basically I have a formula that continues in all directions infinitely (I call it spherical) and after the distance estimate I am using a boolean intersection using a sphere to "cut" the infinitely repeating fractal so only a sphere of it is left. I am then mixing that DE with another. My problem is that because I am cutting the sphere after the orbit trap calculations it is coloring areas where the the fractal no longer exists (ie where the other formula exists).

I tried another approach where I used an if statement to test if the point was within a certain radius but I couldn't seem to get to work but I think that is the way I would have to do it? If it is is possible?

cheers
Keith
« Last Edit: October 29, 2013, 05:44:54 AM by Nahee_Enterprises » Logged
ker2x
Fractal Molossus
**
Posts: 795


WWW
« Reply #3 on: October 28, 2013, 08:44:07 AM »

I don't understand, you want to do CSG ? http://en.wikipedia.org/wiki/Constructive_solid_geometry
Logged

often times... there are other approaches which are kinda crappy until you put them in the context of parallel machines
(en) http://www.blog-gpgpu.com/ , (fr) http://www.keru.org/ ,
Sysadmin & DBA @ http://www.over-blog.com/
eiffie
Guest
« Reply #4 on: October 28, 2013, 05:13:53 PM »

It sounds like you have to orbit trap both formulas then choose which trap to color with by testing which formula you hit.
Logged
tryptophan
Safarist
******
Posts: 86


« Reply #5 on: October 28, 2013, 05:40:15 PM »

Thanks I am using an intersection now but I'm trying to figure out a way not to.  Ah thanks Effie I was just typing my formula now.  Here is the formula:

Code:
par int ColorIterations 2 100 20 val
par int ColoringType 0 4 0 val
par float ColorScale 0.0 2.0 1.0 val
par float ColorOffset -2.0 2.0 0.0 val
par int sIterations 0 100 20 val
par vec3 sOffset -10 10 0 val
par float sZoom 0 4 1 val
par float sScale 0 6 1 val
par float sFatness 0 10 2 val
par vec3 sJulia -10 10 -1 val
par vec2 sJulia2MinMax -1 100 -1 val
par vec3 sJulia2 -10 10 0 val
par float sMoonSize 0 4 1 val

par int kIterations 0 100 20 val
par float kScale 0 6 2 val
par float kFatness 0 5 0 val
par vec3 kOffset -10 10 .5 val
par vec3 kFold -4 4 0 val
par vec3 kJulia -4 4 0 val
par vec3 kJulia2 -4 4 0 val
par vec2 kJulia2MinMax -1 100 -1 val
par vec3 Rotate -360 360 0 val
par vec2 RotMinMax -1 100 -1 val
par float OutputMode 0 1 0 val
par float OrbitSK 0 1 0 val
par vec3 kRotate2 -360 360 0 val

float r;
int n = 0;
mat3 rot;
mat3 rot2;

void init()
{
rot = rotationAngleMatrixXYZ(Rotate);
rot2 = rotationAngleMatrixXYZ(kRotate2);
}

float sminPoly( float a, float b, float k )
{
    float h = clamp( 0.5+0.5*(b-a)/k, 0.0, 1.0 );
    return mix( b, a, h ) - k*h*(1.0-h);
}

float absScalem1 = abs(kScale - 1.0);
float AbsScaleRaisedTo1mIters = pow(abs(kScale), float(1-kIterations));
float absScale = abs(kScale);

float DE(vec3 p)
{
vec3 p2 = p;

orbitTrap = vec4(1000.0);

float fat = sFatness;
vec3 sP = p * sZoom - sOffset;
vec4 sOrbitTrap = orbitTrap;
vec4 kOrbitTrap = orbitTrap;

float dr = 1.0;
int n = 0;

float l = 0;
float prevl = 0;

for( int i=0; i<sIterations;i++ )
{
// Spherical

prevl = l;

sP = abs(sP);
float sR = dot(sP,sP);

   if (i <= ColorIterations)
   {
   if (ColoringType==0) sOrbitTrap = min(sOrbitTrap, vec4((1/sP),sR) );    
   if (ColoringType==1) sOrbitTrap = min(sOrbitTrap, abs(vec4(sP.xyz,0)));
   if (ColoringType==2) sOrbitTrap = min(sOrbitTrap, vec4((1/sP),sR));
   if (ColoringType==3) sOrbitTrap = min(sOrbitTrap, vec4((1/sP),sR));

   //if (ColoringType==2) sOrbitTrap += exp(-1/abs(l+prevl+ColorOffset));
   //if (ColoringType==3) sOrbitTrap+=abs(l-prevl+ColorOffset);
   }
   l = length(sP);
float k = max(sScale/sR,0.1);
sP     *= k;
fat *= k;
sP += sJulia;

if  (i >= int(sJulia2MinMax.x) && i <= int(sJulia2MinMax.y)) sP += sJulia2;
//if  (i >= int(RotMinMax.x) && i <= int(RotMinMax.y)) sP *= rot;
}

l = 0.0;
prevl =0.0;

p *= rot2;

        //IFS
while (n < kIterations)
{
prevl = l;

p-= 2.0 * min(0.0, dot(p, vec3(-0.5, 0.309017, 0.809017))) * vec3(-0.5, 0.309017, 0.809017);
p-= 2.0 * min(0.0, dot(p, vec3(0.309017, 0.809017, -0.5))) * vec3(0.309017, 0.809017, -0.5);
p-= 2.0 * min(0.0, dot(p, vec3(0.809017, -0.5, 0.309017))) * vec3(0.809017, -0.5, 0.309017);
p-= 2.0 * min(0.0, dot(p, vec3(-0.5, 0.309017, 0.809017))) * vec3(-0.5, 0.309017, 0.809017);
p-= 2.0 * min(0.0, dot(p, vec3(0.309017, 0.809017, -0.5))) * vec3(0.309017, 0.809017, -0.5);
p-= 2.0 * min(0.0, dot(p, vec3(0.809017, -0.5, 0.309017))) * vec3(0.809017, -0.5, 0.309017);
p-= 2.0 * min(0.0, dot(p, vec3(-0.5, 0.309017, 0.809017))) * vec3(-0.5, 0.309017, 0.809017);
p-= 2.0 * min(0.0, dot(p, vec3(0.309017, 0.809017, -0.5))) * vec3(0.309017, 0.809017, -0.5);
p-= 2.0 * min(0.0, dot(p, vec3(0.809017, -0.5, 0.309017))) * vec3(0.809017, -0.5, 0.309017);

if (p.x<p.y) p.xy = p.yx;
if (p.x<p.z) p.xz = p.zx;
if (p.y<p.z) p.yz = p.zy;

p -= kJulia;
p = abs(p+kFold)-kFold;
p = p*kScale - kOffset*(kScale-1.0);
float kR = dot(p, p);

if (n <= ColorIterations)
   {
   if (ColoringType==0) kOrbitTrap = min(kOrbitTrap, vec4(p,kR) );    
   if (ColoringType==1) kOrbitTrap = min(kOrbitTrap, abs(vec4(p.xyz,0)));
   if (ColoringType==2) kOrbitTrap = min(min(kOrbitTrap, vec4(p,kR)),sOrbitTrap);
   if (ColoringType==3) kOrbitTrap = min(min(kOrbitTrap, vec4(p,kR)),sOrbitTrap);

   //if (ColoringType==2) kOrbitTrap += exp(-1/abs(l-prevl+ColorOffset));
  //if (ColoringType==3) kOrbitTrap += abs(l-prevl+ColorOffset);
   }

//if (n <= ColorIterations) kOrbitTrap = min(kOrbitTrap, vec4((p),kR) );

dr *= absScale;  
if  (n >= int(kJulia2MinMax.x) && n <= int(kJulia2MinMax.y)) p -= kJulia2;
if  (n >= int(RotMinMax.x) && n <= int(RotMinMax.y)) p *= rot;

l = length(p);

n++;
}

orbitTrap = mix(sOrbitTrap,kOrbitTrap,OrbitSK)* ColorScale + ColorOffset;
//if (ColoringType==3) orbitTrap/=ColorIterations;
//orbitTrap = min(sOrbitTrap,kOrbitTrap);

float d;

d = max(sdSphere(p2,sMoonSize),0.25*length(sP.xyz)/fat);

//float da = length(p)  * pow(kScale, -float(n))-(kFatness * 0.001);

float db = ((length(p) - absScalem1) / dr - AbsScaleRaisedTo1mIters)-(kFatness * 0.001);

//float mn = min(d,db);

float mn = sminPoly(d,db,OutputMode);

return mn;
}

void main() { RayMarchMain(); }

This formula basically blends two formulas an infinitely repeating spherical formula and an IFS but in the line:
Code:
d = max(sdSphere(p2,sMoonSize),0.25*length(sP.xyz)/fat);
A boolean intersection is done on the "Spherical" formula with a sphere so only globe of the "Spherical" formula appears.

What I would like to do is modify the "Spherical" formula so it stops at a certain radius rather than use a boolean.  I've tried something like:
Code:
float dist = length(p);
   if (dist > sMoonSize) break;

in the beginning of the "Spherical" iteration and it does work and does stop the formula from continuing beyond a set size but it doesn't draw properly.  I'm not sure...
« Last Edit: October 29, 2013, 05:54:41 AM by Nahee_Enterprises » Logged
tryptophan
Safarist
******
Posts: 86


« Reply #6 on: October 28, 2013, 05:46:49 PM »

Now though because the boolean is done after the orbit test it will still color the IFS (with Spherical orbit traps) where the Spherical doesn't appear outside of the "globe" radius. It does work perfectly where the Spherical formula doesn't exist within the formula itself. I'll post some images.
Logged
tryptophan
Safarist
******
Posts: 86


« Reply #7 on: October 28, 2013, 06:29:42 PM »

Sorry it wasn't working. So Eiffie I do have two orbit trap formulas but I'm not sure how to test which surface was hit in the renderer?
« Last Edit: October 28, 2013, 06:51:57 PM by tryptophan » Logged
eiffie
Guest
« Reply #8 on: October 28, 2013, 06:49:47 PM »

Here is what I do...

float d1=max(InfiniteFractalDE,SphereDE);
float d2=OtherThingyDE;
float mn=min(d1,d2);
if(abs(mn-d1)<0.0001){//you hit the InfiniteFractal inside the sphere
  orbitTrap=InfiniteFractalOrbitTrap;
}else orbitTrap=OtherThingiesOrbitTrap;

I hope the technical jargon isn't too much smiley
Logged
tryptophan
Safarist
******
Posts: 86


« Reply #9 on: October 28, 2013, 06:58:17 PM »

Sweet!!! I understand! Thanks Effie again for the amazing help.

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


formerly known as 'Trifox'


WWW
« Reply #10 on: October 28, 2013, 07:04:09 PM »

I was about to answer as well but it seems to be settled, i talked about basic de combinations in the tutorial4 of chaostube along with the axolotl script and a sweet smooth min function dont want to spam around so you gotta find it yourself i think it might be of help
Logged

---

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


« Reply #11 on: October 28, 2013, 07:07:51 PM »

Thanks I'll check it out asap. For sure.
Logged
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
animated gif of Amazing Box Folding Operation ? General Discussion cKleinhuis 5 2262 Last post August 20, 2010, 11:21:58 PM
by FractalFoundation
boolean logic meets kifs Images Showcase (Rate My Fractal) visual.bermarte 0 550 Last post October 27, 2010, 08:17:16 PM
by visual.bermarte
Boolean Box of Blue Images Showcase (Rate My Fractal) Alef 1 769 Last post October 30, 2012, 04:22:44 PM
by Alef
Painted Tree In Painted Desert -4 fractal boolean Mandelbulber Gallery mclarekin 0 227 Last post August 05, 2015, 04:59:14 AM
by mclarekin
Improving ChaosPro Operation ChaosPro Kalter Rauch 2 546 Last post July 25, 2017, 03:24:16 AM
by Kalter Rauch

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.188 seconds with 27 queries. (Pretty URLs adds 0.01s, 2q)