Logo by Tglad - 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. May 27, 2022, 09:47:00 PM


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   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: Overlapping spheres?  (Read 3736 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: September 28, 2011, 11:18:43 PM »

I am wondering on this concept. Take the normal 3d space in ortho coords. A sphere lies inside...
(x-x0)**2+(y-y0)**2+(z-z0)**2<=1
okay. think about 2 spheres. r is the distance from each origin as explained
min(r1,r2)<=1
is the region where both spheres exist
max(r1,r2)<=1
gives the intersection
but i wanted to find an appropriate fun of r1 and r2 that
. far from the intersection works as min(r1,r2) or almost like
. near the intersection "melts" the spheres in some way
what should I use as f? wondering of an exp smoothing but how?
thanks
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: September 28, 2011, 11:48:51 PM »

Like in this example www.shipbrook.com/jeff/raytrace/blobs.html smiley
Logged

No sweat, guardian of wisdom!
marius
Fractal Lover
**
Posts: 206


« Reply #2 on: September 29, 2011, 01:03:18 AM »


Have you seen http://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm ?
Distance estimation oriented but why would you want it any other way  grin
Logged
fractower
Iterator
*
Posts: 173


« Reply #3 on: September 29, 2011, 03:16:35 AM »

I have played with a number of partition functions while trying to spatially combine two mandelbulbs separated in space. The parameter a controls the abruptness of the transition. It is also extendable to and many circles as you want.

r_min ~=  (r1 * exp(-a*r1^2) + r2 * exp(-a*r2^2))/(exp(-a*r1^2) + exp(-a*r2^2))

Changing the sign in the exp will give you r_max.

A couple of examples. No bulbs were hurt in the creation of these images.
http://nocache-nocookies.digitalgott.com/gallery/6/2792_06_04_11_8_51_21.jpeg
http://nocache-nocookies.digitalgott.com/gallery/6/2792_04_04_11_9_35_59.jpeg
« Last Edit: September 29, 2011, 04:00:10 AM by fractower » Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #4 on: September 29, 2011, 12:08:43 PM »


Wooo!!!! GREAT find.  cheesy but:

Blend

float opBlend( vec3 p )
{
    float d1 = primitiveA(p);
    float d2 = primitiveB(p);
    floar dd = smoothcurve(d1-d2);
    return mix(d1,d2,dd);
}

He forgot to tell what is mix() and smoothcurve()  huh? fiery fiery

Luca Azn
Logged

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


Fragments of the fractal -like the tip of it


« Reply #5 on: September 29, 2011, 12:10:37 PM »

I have played with a number of partition functions while trying to spatially combine two mandelbulbs separated in space. The parameter a controls the abruptness of the transition. It is also extendable to and many circles as you want.

r_min ~=  (r1 * exp(-a*r1^2) + r2 * exp(-a*r2^2))/(exp(-a*r1^2) + exp(-a*r2^2))

Changing the sign in the exp will give you r_max.

A couple of examples. No bulbs were hurt in the creation of these images.
http://nocache-nocookies.digitalgott.com/gallery/6/2792_06_04_11_8_51_21.jpeg
http://nocache-nocookies.digitalgott.com/gallery/6/2792_04_04_11_9_35_59.jpeg

Fantastic! I will definitely try it!  kiss
Logged

No sweat, guardian of wisdom!
subblue
Conqueror
*******
Posts: 116



WWW
« Reply #6 on: September 29, 2011, 05:16:18 PM »

He forgot to tell what is mix() and smoothcurve()

mix(a, b, c): result =a when c <= 0 and =b when c >= 1 with a linear blend inbetween

I'm guessing smoothcurve is like the smoothstep function in OpenGL, which (from the spec):

Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth Hermite interpolation between 0 and 1 when edge0 < x < edge1.  This is useful in cases where you would want a threshold function with a smooth transition.
This is equivalent to:
   t = clamp ((x – edge0) / (edge1 – edge0), 0, 1);
   return t * t * (3 – 2 * t);
Logged

www.subblue.com - a blog exploring mathematical and generative graphics
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #7 on: September 29, 2011, 05:39:19 PM »

He forgot to tell what is mix() and smoothcurve()

mix(a, b, c): result =a when c <= 0 and =b when c >= 1 with a linear blend inbetween

I'm guessing smoothcurve is like the smoothstep function in OpenGL, which (from the spec):

Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth Hermite interpolation between 0 and 1 when edge0 < x < edge1.  This is useful in cases where you would want a threshold function with a smooth transition.
This is equivalent to:
   t = clamp ((x – edge0) / (edge1 – edge0), 0, 1);
   return t * t * (3 – 2 * t);


I found a very similar answer in google. smiley tyty!!!
Logged

No sweat, guardian of wisdom!
Syntopia
Fractal Molossus
**
Posts: 681



syntopiadk
WWW
« Reply #8 on: September 29, 2011, 11:33:26 PM »

I played around with this exact problem some weeks ago.

I never really understood Quilez's formula. If I use smoothcurve(d1-d2) = smoothstep(0,1,d1-d2), I get some very asymmetric objects, not very blobby (see the top of attached pictures).

Also, if you look at slide 42 in his 'Rendering Worlds...' (http://www.iquilezles.org/www/material/nvscene2008/rwwtt.pdf), he uses a different formula - here he uses a global distance to interpolate: smoothstep(length(p),0,1) - notice the order of arguments?. And if you look at the Slisesix demo code, it seems he just mixes linearly ("float a = clamp( r*3.0, 0.0, 1.0 ); return c*a + d*(1.0-a);").

I came up with the following formula, which mixes linearly based on the distance from the center of each object (I could not find a good formula based on the ratios of the distance estimates, even though I would have preferred it). Fragmentarium code:

Code:
include "DE-Raytracer.frag"
uniform float Dist; slider[0,1,2]
uniform float n; slider[0,1,10]

float sdSphere(vec3 p, float s) {  return length(p)-s; }

vec3 C1 = vec3(Dist,0,0);
vec3 C2 = vec3(-Dist,0,0);

float DE( vec3 p )
{
float d1 = sdSphere(p-C1,1.0);
float d2 = sdSphere(p-C2,1.0);
float r1 = length(p-C1);
float r2 = length(p-C2);
float m = r1/(r1+r2);
return mix(d1,d2,m);
}

This produces the lower image.

I also just tried fractowers formula, but it seems not very 'blobby' to me either - at least not if the r1 and r2 are distance estimates. It does, however, provide a nice controllable weighting if you mix the distance estimates by the distances to the center:

Code:
return (d1*exp(-A*r1*r1) + d2*exp(-A*r2*r2)) / (exp(-A*r1*r1) + exp(-A*r2*r2));


* spheres.jpg (36.41 KB, 544x678 - viewed 242 times.)
Logged
Syntopia
Fractal Molossus
**
Posts: 681



syntopiadk
WWW
« Reply #9 on: September 30, 2011, 12:05:21 AM »

I just realized that there is a much simpler way:

Just take the union with the product of the distance estimates:

Code:
float DE( vec3 p )
{
float d1 = sdSphere(p-C1,1.0);
float d2 = sdSphere(p-C2,1.0);
return min(min(d1,d2),n*d1*d2);
}

This gives a nice symmetric blobby interpolation, and the blobbiness can be controlled by adjusting the 'n' factor.
Besides that, it uses only distance estimates, and also works for unsigned distances. It also has the nice property that it will always add to volume, never remove from it.

Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #10 on: September 30, 2011, 12:20:20 AM »

Fantastic ... Thanks for those replies smiley
Logged

No sweat, guardian of wisdom!
fractower
Iterator
*
Posts: 173


« Reply #11 on: September 30, 2011, 12:47:25 AM »

The formula I originally provided returns a value with a lower bound of min(r1,r2). To get the blobby stuff you will need a formula the treates min(r1,r2) as an upper bound. This can be done by using a harmonic addition.

r_min ~=  (exp(-a*r1^2) + exp(-a*r2^2))/((1/r1) * exp(-a*r1^2) + (1/r2) * exp(-a*r2^2))

or

r_min = 1/(1/r1 + 1/r2).

I usually protect against devide by zero with 1/(r+.00000001)
Logged
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #12 on: September 30, 2011, 08:31:28 AM »

Anyway, reading the original blob article, I think that the accurate fmla shoul depend on a min and max radii.
under the min rad nothing should happen (so we can take safely min(r1,r2)
over it we can start mangling. I think that syntopia's approach is good, edventually fixed with an exponential function? To emulate the "thin bridge" effect (the plasticity should be adjusted with a max/minrad factor in the original blob method).
To see things clearly anyway I need more images and to test by myself. There is no hurry cheesy
Logged

No sweat, guardian of wisdom!
KRAFTWERK
Global Moderator
Fractal Senior
******
Posts: 1439


Virtual Surreality


WWW
« Reply #13 on: September 30, 2011, 09:24:43 AM »

Wow... This sounds tasty!  afro A Beer Cup
Logged

DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #14 on: September 30, 2011, 09:40:19 AM »

Wow... This sounds tasty!  afro A Beer Cup
Sure! Think about a blob-based folding or sphere inversion or decombine cheesy
For now decombines are "static" anyways
Logged

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

Related Topics
Subject Started by Replies Views Last post
Reflexions in spheres? Mandelbulb3D Gallery bib 0 785 Last post October 24, 2010, 09:54:58 PM
by bib
The Marble Spheres Mandelbulb3D Gallery Lee Oliver 0 512 Last post August 11, 2011, 05:06:28 AM
by Lee Oliver
Propagation of a crystalline universe of cubes and spheres Mandelbulb3D Gallery KRAFTWERK 0 379 Last post February 01, 2012, 03:28:14 PM
by KRAFTWERK
Spheres on spheres Mandelbulb3D Gallery bib 7 709 Last post March 20, 2012, 09:43:29 AM
by DarkBeam
SPHERES...Spheres...spheres... Mandelbulber Gallery Buddhi 0 527 Last post August 23, 2015, 10:14:39 PM
by Buddhi

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