POV-Ray : Newsgroups : povray.binaries.images : Sphere Sponge Server Time
15 Nov 2024 00:18:42 EST (-0500)
  Sphere Sponge (Message 1 to 9 of 9)  
From: Jonathan Hunt
Subject: Sphere Sponge
Date: 26 Oct 2008 08:08:53
Message: <49045dd5@news.povray.org>
Recipe
------
* Take one Menger Sponge (Level according to taste).
* Chop off, diagonally, the eight corners.
* Inflate the sides until spherical.
* Polish until slightly reflective.
* Place on a micro-normal-blurred reflective surface.
* Replicate about 500 times.
* Add an area light for soft shadows.
* Turn on radiosity and focal blur.
* Render for 30 days or until done.


Post a reply to this message


Attachments:
Download 'spheresponge.jpg' (699 KB)

Preview of image 'spheresponge.jpg'
spheresponge.jpg


 

From: nemesis
Subject: Re: Sphere Sponge
Date: 26 Oct 2008 14:16:35
Message: <4904b403$1@news.povray.org>
Jonathan Hunt wrote:
> Recipe
> ------
> * Take one Menger Sponge (Level according to taste).
> * Chop off, diagonally, the eight corners.
> * Inflate the sides until spherical.
> * Polish until slightly reflective.
> * Place on a micro-normal-blurred reflective surface.
> * Replicate about 500 times.
> * Add an area light for soft shadows.
> * Turn on radiosity and focal blur.
> * Render for 30 days or until done.
> 
> ------------------------------------------------------------------------
> 

Dude, you really came back to pov with a revenge, huh?! o_O

That's friggin terrific!


Post a reply to this message

From: Carlo C 
Subject: Re: Sphere Sponge
Date: 27 Oct 2008 04:35:01
Message: <web.49057d1bf38084311dfe37a90@news.povray.org>
Jonathan Hunt <jon### [at] xlcuscom> wrote:
> Recipe
> ------
> * Take one Menger Sponge (Level according to taste).
> * Chop off, diagonally, the eight corners.
> * Inflate the sides until spherical.
> * Polish until slightly reflective.
> * Place on a micro-normal-blurred reflective surface.
> * Replicate about 500 times.
> * Add an area light for soft shadows.
> * Turn on radiosity and focal blur.
> * Render for 30 days or until done.

A math masterpiece!


Post a reply to this message

From: Kevin Wampler
Subject: Re: Sphere Sponge
Date: 27 Oct 2008 18:12:06
Message: <49063cb6$1@news.povray.org>
That is very cool, well done!


Post a reply to this message

From: Jonathan Hunt
Subject: Re: Sphere Sponge
Date: 27 Oct 2008 19:32:28
Message: <49064f8c@news.povray.org>
Thanks for the nice comments.  Here's some information for those 
interested in the structure of the object.

I started with my non-recursive Menger Sponger isosurface function...

function
{
  max
  (
   #declare Level = 4;
   #declare Size = 0.5;
   #while (Level > 0)
    #declare Size = Size / 3;
    min(Size-abs(mod(x,Size*6)-Size*3),Size-abs(mod(y,Size*6)-Size*3)),
    min(Size-abs(mod(y,Size*6)-Size*3),Size-abs(mod(z,Size*6)-Size*3)),
    min(Size-abs(mod(z,Size*6)-Size*3),Size-abs(mod(x,Size*6)-Size*3))
    #declare Level = Level - 1;
    #if (Level > 0) , #end
   #end
  )
}



Contained and chopped the corners off with further "max" constraints to 
form a cuboctahedron...

#declare Sponge = function
{
  max
  (
   #declare Level = 4;
   #declare Size = 0.5;
   #while (Level > 0)
    #declare Size = Size / 3;
    min(Size-abs(mod(x,Size*6)-Size*3),Size-abs(mod(y,Size*6)-Size*3)),
    min(Size-abs(mod(y,Size*6)-Size*3),Size-abs(mod(z,Size*6)-Size*3)),
    min(Size-abs(mod(z,Size*6)-Size*3),Size-abs(mod(x,Size*6)-Size*3)),
    #declare Level = Level - 1;
   #end
   x-1, -x,
   y-1, -y,
   z-1, -z,

   -x+y-z-0.5,
   +x+y-z-1.5,
   -x-y-z+0.5,
   +x-y-z-0.5,
   -x+y+z-1.5,
   +x+y+z-2.5,
   -x-y+z-0.5,
   +x-y+z-1.5
  )
}


Then made a mapping that transformed any coordinate within a sphere to a 
coordinate within the cuboctahedron such that any point on the surface 
of the sphere would also fall on the surface of the cuboctahedron...

#declare SphereTransX = function { x * sqrt(x*x+y*y+z*z) / 
max(abs(x),abs(y),abs(z),(abs(x)+abs(y)+abs(z))/2) }
#declare SphereTransY = function { y * sqrt(x*x+y*y+z*z) / 
max(abs(x),abs(y),abs(z),(abs(x)+abs(y)+abs(z))/2) }
#declare SphereTransZ = function { z * sqrt(x*x+y*y+z*z) / 
max(abs(x),abs(y),abs(z),(abs(x)+abs(y)+abs(z))/2) }


 From there I could simply define my Sphere Sponge as...

#declare SphereSponge = isosurface
{
  function
  {
   Sponge
   (
    SphereTransX(x-0.5,y-0.5,z-0.5)+0.5,
    SphereTransY(x-0.5,y-0.5,z-0.5)+0.5,
    SphereTransZ(x-0.5,y-0.5,z-0.5)+0.5
   )
  }
  contained_by { sphere { 0.5, 0.5 } }
}


Post a reply to this message

From: nemesis
Subject: Re: Sphere Sponge
Date: 27 Oct 2008 19:36:34
Message: <49065082@news.povray.org>
Jonathan Hunt wrote:
> Thanks for the nice comments.  Here's some information for those 
> interested in the structure of the object.
> 
> I started with my non-recursive Menger Sponger isosurface function...
> 
> function
> {
>  max
>  (
>   #declare Level = 4;
>   #declare Size = 0.5;
>   #while (Level > 0)
>    #declare Size = Size / 3;
>    min(Size-abs(mod(x,Size*6)-Size*3),Size-abs(mod(y,Size*6)-Size*3)),
>    min(Size-abs(mod(y,Size*6)-Size*3),Size-abs(mod(z,Size*6)-Size*3)),
>    min(Size-abs(mod(z,Size*6)-Size*3),Size-abs(mod(x,Size*6)-Size*3))
>    #declare Level = Level - 1;
>    #if (Level > 0) , #end
>   #end
>  )
> }
> 
> 
> 
> Contained and chopped the corners off with further "max" constraints to 
> form a cuboctahedron...
> 
> #declare Sponge = function
> {
>  max
>  (
>   #declare Level = 4;
>   #declare Size = 0.5;
>   #while (Level > 0)
>    #declare Size = Size / 3;
>    min(Size-abs(mod(x,Size*6)-Size*3),Size-abs(mod(y,Size*6)-Size*3)),
>    min(Size-abs(mod(y,Size*6)-Size*3),Size-abs(mod(z,Size*6)-Size*3)),
>    min(Size-abs(mod(z,Size*6)-Size*3),Size-abs(mod(x,Size*6)-Size*3)),
>    #declare Level = Level - 1;
>   #end
>   x-1, -x,
>   y-1, -y,
>   z-1, -z,
> 
>   -x+y-z-0.5,
>   +x+y-z-1.5,
>   -x-y-z+0.5,
>   +x-y-z-0.5,
>   -x+y+z-1.5,
>   +x+y+z-2.5,
>   -x-y+z-0.5,
>   +x-y+z-1.5
>  )
> }
> 
> 
> Then made a mapping that transformed any coordinate within a sphere to a 
> coordinate within the cuboctahedron such that any point on the surface 
> of the sphere would also fall on the surface of the cuboctahedron...
> 
> #declare SphereTransX = function { x * sqrt(x*x+y*y+z*z) / 
> max(abs(x),abs(y),abs(z),(abs(x)+abs(y)+abs(z))/2) }
> #declare SphereTransY = function { y * sqrt(x*x+y*y+z*z) / 
> max(abs(x),abs(y),abs(z),(abs(x)+abs(y)+abs(z))/2) }
> #declare SphereTransZ = function { z * sqrt(x*x+y*y+z*z) / 
> max(abs(x),abs(y),abs(z),(abs(x)+abs(y)+abs(z))/2) }
> 
> 
>  From there I could simply define my Sphere Sponge as...
> 
> #declare SphereSponge = isosurface
> {
>  function
>  {
>   Sponge
>   (
>    SphereTransX(x-0.5,y-0.5,z-0.5)+0.5,
>    SphereTransY(x-0.5,y-0.5,z-0.5)+0.5,
>    SphereTransZ(x-0.5,y-0.5,z-0.5)+0.5
>   )
>  }
>  contained_by { sphere { 0.5, 0.5 } }
> }

Gosh!  And somehow I was under the impression it could be some insane 
CSG under the hoods... :P


Post a reply to this message

From: Dre
Subject: Re: Sphere Sponge
Date: 27 Oct 2008 20:03:12
Message: <490656c0$1@news.povray.org>
"Jonathan Hunt" <jon### [at] xlcuscom> wrote in message 
news:49064f8c@news.povray.org...
> Thanks for the nice comments.  Here's some information for those 
> interested in the structure of the object.
>
> I started with my non-recursive Menger Sponger isosurface function...
>
> function
> {
>  max
>  (
>   #declare Level = 4;
>   #declare Size = 0.5;
>   #while (Level > 0)
>    #declare Size = Size / 3;
>    min(Size-abs(mod(x,Size*6)-Size*3),Size-abs(mod(y,Size*6)-Size*3)),
>    min(Size-abs(mod(y,Size*6)-Size*3),Size-abs(mod(z,Size*6)-Size*3)),
>    min(Size-abs(mod(z,Size*6)-Size*3),Size-abs(mod(x,Size*6)-Size*3))
>    #declare Level = Level - 1;
>    #if (Level > 0) , #end
>   #end
>  )
> }
>
>
>
> Contained and chopped the corners off with further "max" constraints to 
> form a cuboctahedron...
>
> #declare Sponge = function
> {
>  max
>  (
>   #declare Level = 4;
>   #declare Size = 0.5;
>   #while (Level > 0)
>    #declare Size = Size / 3;
>    min(Size-abs(mod(x,Size*6)-Size*3),Size-abs(mod(y,Size*6)-Size*3)),
>    min(Size-abs(mod(y,Size*6)-Size*3),Size-abs(mod(z,Size*6)-Size*3)),
>    min(Size-abs(mod(z,Size*6)-Size*3),Size-abs(mod(x,Size*6)-Size*3)),
>    #declare Level = Level - 1;
>   #end
>   x-1, -x,
>   y-1, -y,
>   z-1, -z,
>
>   -x+y-z-0.5,
>   +x+y-z-1.5,
>   -x-y-z+0.5,
>   +x-y-z-0.5,
>   -x+y+z-1.5,
>   +x+y+z-2.5,
>   -x-y+z-0.5,
>   +x-y+z-1.5
>  )
> }
>
>
> Then made a mapping that transformed any coordinate within a sphere to a 
> coordinate within the cuboctahedron such that any point on the surface of 
> the sphere would also fall on the surface of the cuboctahedron...
>
> #declare SphereTransX = function { x * sqrt(x*x+y*y+z*z) / 
> max(abs(x),abs(y),abs(z),(abs(x)+abs(y)+abs(z))/2) }
> #declare SphereTransY = function { y * sqrt(x*x+y*y+z*z) / 
> max(abs(x),abs(y),abs(z),(abs(x)+abs(y)+abs(z))/2) }
> #declare SphereTransZ = function { z * sqrt(x*x+y*y+z*z) / 
> max(abs(x),abs(y),abs(z),(abs(x)+abs(y)+abs(z))/2) }
>
>
> From there I could simply define my Sphere Sponge as...
>
> #declare SphereSponge = isosurface
> {
>  function
>  {
>   Sponge
>   (
>    SphereTransX(x-0.5,y-0.5,z-0.5)+0.5,
>    SphereTransY(x-0.5,y-0.5,z-0.5)+0.5,
>    SphereTransZ(x-0.5,y-0.5,z-0.5)+0.5
>   )
>  }
>  contained_by { sphere { 0.5, 0.5 } }
> }

Great, thanks for that, I'm going to have a play with that later tonight!

Cheers Dre


Post a reply to this message

From: Jonathan Hunt
Subject: Re: Sphere Sponge
Date: 28 Oct 2008 19:40:49
Message: <4907a301@news.povray.org>
nemesis wrote:
> Gosh!  And somehow I was under the impression it could be some insane 
> CSG under the hoods... :P

Hehe :-)  The really nice thing about defining it as an Isosurface is 
that you can make it as complicated as you want (i.e. render the sponge 
at any level you want) without taking up tons and tons of memory.

The real limit then becomes how many pixels you have on the screen to 
visualize the beast! :-)

-- 
Jonathan Hunt
jon### [at] xlcuscom


Post a reply to this message

From: Jonathan Hunt
Subject: Re: Sphere Sponge
Date: 29 Oct 2008 15:37:57
Message: <4908bb95$1@news.povray.org>
Dre wrote:
> Great, thanks for that, I'm going to have a play with that
 > later tonight!

I almost forgot...

If you can compile your own version of POV-Ray, you may be interested in 
this trick to speed up rendering *A LOT*

Load up isosurf.cpp, scroll down to the bottom, and replace the 
Evaluate_Fuction code with the code shown below.  This is basically a 
pure C code version of my Sphere Sponge isosurface function, and as you 
can imagine, can be evaluated much faster than the parsed SDL version.


DBL Evaluate_Function(FUNCTION funct, VECTOR fnvec)
{
	DBL result = -1.0;

	DBL x = fnvec[X]-0.5;
	DBL y = fnvec[Y]-0.5;
	DBL z = fnvec[Z]-0.5;

	DBL max = fabs(x);
	if (fabs(y) > max) { max = fabs(y); }
	if (fabs(z) > max) { max = fabs(z); }
	if ((fabs(x)+fabs(y)+fabs(z))/2 > max) { max = 
(fabs(x)+fabs(y)+fabs(z))/2; }

	DBL sphereScale = sqrt(x*x+y*y+z*z) / max;

	x *= sphereScale;
	y *= sphereScale;
	z *= sphereScale;

	x += 0.5;
	y += 0.5;
	z += 0.5;

	DBL size = 0.5;
	for (int level = 4; level > 0; --level)
	{
		size /= 3.0;

		DBL a = size - fabs(fmod(x,size*6.0)-size*3.0);
		DBL b = size - fabs(fmod(y,size*6.0)-size*3.0);
		DBL c = size - fabs(fmod(z,size*6.0)-size*3.0);

		if (a < b)
		{
			if (a > result) { result = a; }
		}
		else
		{
			if (b > result) { result = b; }
		}

		if (b < c)
		{
			if (b > result) { result = b; }
		}
		else
		{
			if (c > result) { result = c; }
		}

		if (c < a)
		{
			if (c > result) { result = c; }
		}
		else
		{
			if (a > result) { result = a; }
		}
	}

	if (x-1 > result) { result = x-1; }
	if (y-1 > result) { result = y-1; }
	if (z-1 > result) { result = z-1; }
	if (-x > result) { result = -x; }
	if (-y > result) { result = -y; }
	if (-z > result) { result = -z; }

	if (-x+y-z-0.5 > result) { result = -x+y-z-0.5; }
	if (+x+y-z-1.5 > result) { result = +x+y-z-1.5; }
	if (-x-y-z+0.5 > result) { result = -x-y-z+0.5; }
	if (+x-y-z-0.5 > result) { result = +x-y-z-0.5; }
	if (-x+y+z-1.5 > result) { result = -x+y+z-1.5; }
	if (+x+y+z-2.5 > result) { result = +x+y+z-2.5; }
	if (-x-y+z-0.5 > result) { result = -x-y+z-0.5; }
	if (+x-y+z-1.5 > result) { result = +x-y+z-1.5; }

    	return result;
}


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.