POV-Ray : Newsgroups : povray.general : Blobs help Server Time
4 Nov 2024 13:01:15 EST (-0500)
  Blobs help (Message 1 to 9 of 9)  
From: SharkD
Subject: Blobs help
Date: 10 Nov 2008 12:55:01
Message: <web.4918748ab3c4f15b1f5ffef0@news.povray.org>
The example blob function at the end of the isosurface tutorial behaves
differently at different scales, as can be seen in the example below. This is
not a problem with the built-in blob object. I was wondering if anyone could
provide a better formula for when using isosurfaces? Thanks!

// Begin

#version 3.6;

#include "colors.inc"
#include "functions.inc"
#include "math.inc"
#include "Axes_macro.inc"

#declare Scene_scale = frame_number;

global_settings
{
 assumed_gamma 1.0
 max_trace_level 5
}

// ----------------------------------------

#declare screen_scale = 1;
camera
{
 #local CameraDistance = 10;
 #local ScreenArea = 6;
 #local AspectRatio = image_width/image_height;
 orthographic
 location -z*CameraDistance
 direction z*CameraDistance
 right     x*ScreenArea*AspectRatio
 up        y*ScreenArea
 rotate x*asind(tand(30))
// rotate x*90
 rotate y*45
 scale Scene_scale
}


background { color rgb <0.6,0.7,1.0> }

light_source
{
 <0, 0, 0>            // light's position (translated below)
 color rgb <1, 1, 1>  // light's color
 translate <-30, 30, -30>
 shadowless
 scale Scene_scale
}

light_source
{
 <0, 0, 0>            // light's position (translated below)
 color rgb <1, 1, 1>  // light's color
 translate <-30, 30, -30>
 rotate y * 90
 shadowless
 scale Scene_scale
}

plane { y,0 pigment {color rgbt 1/2}}

// ----------------------------------------

#declare Blob_threshold = 0.5;
#declare Blob_start = 1;
#declare fn_A = function { pow(x+Scene_scale/2,2) + pow(y+Scene_scale/2,2) +
pow(z+Scene_scale/2,2) - pow(Scene_scale,2) };
#declare fn_B = function { pow(x-Scene_scale/2,2) + pow(y-Scene_scale/2,2) +
pow(z-Scene_scale/2,2) - pow(Scene_scale,2) };
#declare fn_C = function { Blob_start + Blob_threshold }

difference
{
 isosurface
 {
  function
  {
   fn_C(x,y,z)
   - pow(Blob_threshold, fn_A(x,y,z))
   - pow(Blob_threshold, fn_B(x,y,z))
  }
  threshold 0
  accuracy 0.001*Scene_scale
  max_gradient 4
  contained_by { sphere { 0, 2 * Scene_scale } }
 }
 pigment {color rgb x}
}

// End


Post a reply to this message

From: Dan Connelly
Subject: Re: Blobs help
Date: 10 Nov 2008 13:59:32
Message: <49188494@news.povray.org>
SharkD wrote:

> #declare Blob_threshold = 0.5;
> #declare Blob_start = 1;
> #declare fn_A = function { pow(x+Scene_scale/2,2) + pow(y+Scene_scale/2,2) +
> pow(z+Scene_scale/2,2) - pow(Scene_scale,2) };
> #declare fn_B = function { pow(x-Scene_scale/2,2) + pow(y-Scene_scale/2,2) +
> pow(z-Scene_scale/2,2) - pow(Scene_scale,2) };
> #declare fn_C = function { Blob_start + Blob_threshold }


Shouldn't this be something like:

#declare fn_A =
   function {
     pow(x/Scene_scale+1/2,2) +
     pow(y/Scene_scale+1/2,2) +
     pow(z/Scene_scale+1/2,2) -
     1 };

etc?


Post a reply to this message

From: SharkD
Subject: Re: Blobs help
Date: 10 Nov 2008 19:50:01
Message: <web.4918d5ff2cced725b9b4c0ae0@news.povray.org>
Dan Connelly <djc### [at] yahoocom> wrote:
> SharkD wrote:
>
> > #declare Blob_threshold = 0.5;
> > #declare Blob_start = 1;
> > #declare fn_A = function { pow(x+Scene_scale/2,2) + pow(y+Scene_scale/2,2) +
> > pow(z+Scene_scale/2,2) - pow(Scene_scale,2) };
> > #declare fn_B = function { pow(x-Scene_scale/2,2) + pow(y-Scene_scale/2,2) +
> > pow(z-Scene_scale/2,2) - pow(Scene_scale,2) };
> > #declare fn_C = function { Blob_start + Blob_threshold }
>
>
> Shouldn't this be something like:
>
> #declare fn_A =
>    function {
>      pow(x/Scene_scale+1/2,2) +
>      pow(y/Scene_scale+1/2,2) +
>      pow(z/Scene_scale+1/2,2) -
>      1 };
>
> etc?

Could you please explain why?

-Mike


Post a reply to this message

From: Dan Connelly
Subject: Re: Blobs help
Date: 10 Nov 2008 20:26:27
Message: <4918DF43.1030001@yahoo.com>
S
>> #declare fn_A =
>>    function {
>>      pow(x/Scene_scale+1/2,2) +
>>      pow(y/Scene_scale+1/2,2) +
>>      pow(z/Scene_scale+1/2,2) -
>>      1 };
>>
>> etc?
> 
> Could you please explain why?
> 
> -Mike
> 

So the function "spreads out" as the multiplication factor changes, but that the value
at a given scaled value of (x,y,z) doesn't change.


Post a reply to this message

From: Dan Connelly
Subject: Re: Blobs help
Date: 10 Nov 2008 20:26:31
Message: <4918DF48.80003@yahoo.com>
S
>> #declare fn_A =
>>    function {
>>      pow(x/Scene_scale+1/2,2) +
>>      pow(y/Scene_scale+1/2,2) +
>>      pow(z/Scene_scale+1/2,2) -
>>      1 };
>>
>> etc?
> 
> Could you please explain why?
> 
> -Mike
> 

So the function "spreads out" as the multiplication factor changes, but that the value
at a given scaled value of (x,y,z) doesn't change.


Post a reply to this message

From: SharkD
Subject: Re: Blobs help
Date: 10 Nov 2008 21:25:00
Message: <web.4918ec8c2cced725aa1dde120@news.povray.org>
"SharkD" <nomail@nomail> wrote:
> The example blob function at the end of the isosurface tutorial behaves
> differently at different scales, as can be seen in the example below. This is
> not a problem with the built-in blob object. I was wondering if anyone could
> provide a better formula for when using isosurfaces? Thanks!

I found to equations that fit the bill. However, I don't know which one to
choose. Both are said to model the behavior of electric fields. One is from
Wikipedia, the other is from a GameDev.net article.


Here is the first:

#declare Blob_threshold = pow(2,frame_number-3);
#declare fn_A = function { 1.5*Scene_scale / sqrt(pow(x+1*Scene_scale,2) +
pow(y,2) + pow(z,2)) };
#declare fn_B = function { 1.5*Scene_scale / sqrt(pow(x-1*Scene_scale,2) +
pow(y,2) + pow(z,2)) };
#declare fn_C = function { Blob_threshold };
#declare fn_D = function { fn_A(x,y,z) + fn_B(x,y,z) - fn_C(x,y,z) };
#declare fn_E = function { max(0,min(1,fn_D(x,y,z))) };


Here is the second:

#declare Blob_threshold = clock;
#declare fn_A = function { 1.5*Scene_scale / (pow(x+1*Scene_scale,2) + pow(y,2)
+ pow(z,2)) };
#declare fn_B = function { 1.5*Scene_scale / (pow(x-1*Scene_scale,2) + pow(y,2)
+ pow(z,2)) };
#declare fn_C = function { Blob_threshold };
#declare fn_D = function { fn_A(x,y,z) + fn_B(x,y,z) - fn_C(x,y,z) };
#declare fn_E = function { max(0,min(1,fn_D(x,y,z))) };


Which of the two is correct in terms of modeling nature?

-Mike


Post a reply to this message

From: SharkD
Subject: Re: Blobs help
Date: 10 Nov 2008 21:25:01
Message: <web.4918ecf12cced725aa1dde120@news.povray.org>
Dan Connelly <djc### [at] yahoocom> wrote:
> S
> >> #declare fn_A =
> >>    function {
> >>      pow(x/Scene_scale+1/2,2) +
> >>      pow(y/Scene_scale+1/2,2) +
> >>      pow(z/Scene_scale+1/2,2) -
> >>      1 };
> >>
> >> etc?
> >
> > Could you please explain why?
> >
> > -Mike
> >
>
> So the function "spreads out" as the multiplication factor changes, but that the
value at a given scaled value of (x,
y,z) doesn't change.

I can't argue as to its merits. It is simply the function I copied from the
isosurface tutorial.

-Mike


Post a reply to this message

From: SharkD
Subject: Re: Blobs help
Date: 12 Nov 2008 21:30:00
Message: <web.491b902d2cced725ab9780f0@news.povray.org>
"SharkD" <nomail@nomail> wrote:
> The example blob function at the end of the isosurface tutorial behaves
> differently at different scales, as can be seen in the example below. This is
> not a problem with the built-in blob object. I was wondering if anyone could
> provide a better formula for when using isosurfaces? Thanks!

Success!

I managed through trial and error to eliminate the variables that caused the
function to be affected by scale.

#declare Blob_threshold = clock;
#declare Blob_start = 1;
#declare fn_A = function { (pow(x+1*Scene_scale,2) + pow(y,2) + pow(z,2) -
pow(1.5*Scene_scale,2)) / pow(Scene_scale,2) };
#declare fn_B = function { (pow(x-1*Scene_scale,2) + pow(y,2) + pow(z,2) -
pow(1.5*Scene_scale,2)) / pow(Scene_scale,2) };
#declare fn_C = function { (Blob_threshold + Blob_start) }
#declare fn_D = function { pow(Blob_threshold, fn_A(x,y,z)) +
pow(Blob_threshold, fn_B(x,y,z)) - fn_C(x,y,z) };
#declare fn_E = function { max(0,min(1,fn_D(x,y,z))) };

The next step is to duplicate the results of the internal "blob" object.


Post a reply to this message

From: SharkD
Subject: Re: Blobs help
Date: 19 Nov 2008 03:10:00
Message: <web.4923c93e2cced7254c536f040@news.povray.org>
"SharkD" <nomail@nomail> wrote:
> Success!
>
> I managed through trial and error to eliminate the variables that caused the
> function to be affected by scale.
>
> ...
>
> The next step is to duplicate the results of the internal "blob" object.

I've compiled what I've learned about blobs, here:

http://www.geogebra.org/en/upload/files/english/Michael_Horvath/Metaballs/geogebra_metaballs.htm

I'd appreciate any insights you might have regarding this class of shapes.

-Mike


Post a reply to this message

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