POV-Ray : Newsgroups : povray.general : Isosurface help Server Time
27 Nov 2024 08:31:48 EST (-0500)
  Isosurface help (Message 1 to 10 of 12)  
Goto Latest 10 Messages Next 2 Messages >>>
From: sumdumguy
Subject: Isosurface help
Date: 22 Jan 2009 01:40:01
Message: <web.497813d6c397323e3b34ecfe0@news.povray.org>
This is more or less a math question not syntax question. Still, I have killed
many hours on this and so maybe someone has an idea.
Say I have an isosurface:


#declare  P = function {x*x + y*y + z*z - 1}

isosurface {
        function {P(x*2,y*(1.05-y/6),z*2)}
        threshold 1
        accuracy 0.001
        max_gradient 200
        contained_by{sphere{<0,0,0>,3}}
        pigment {rgbt <0,1,0>}
}

This gives a stretched sphere where one side is squashed and the other
is more sharp. Now what I want to do is to modify this isosurface so that
there is also a bump on the surface, kind of like a wart on the nose.
Any ideas on how to do this would be appreciated.


Post a reply to this message

From: Mike Williams
Subject: Re: Isosurface help
Date: 22 Jan 2009 02:10:06
Message: <eKdRUPKLuBeJFw9n@econym.demon.co.uk>
Wasn't it sumdumguy who wrote:
>This is more or less a math question not syntax question. Still, I have killed
>many hours on this and so maybe someone has an idea.
>Say I have an isosurface:
>
>
>#declare  P = function {x*x + y*y + z*z - 1}
>
>isosurface {
>        function {P(x*2,y*(1.05-y/6),z*2)}
>        threshold 1
>        accuracy 0.001
>        max_gradient 200
>        contained_by{sphere{<0,0,0>,3}}
>        pigment {rgbt <0,1,0>}
>}
>
>This gives a stretched sphere where one side is squashed and the other
>is more sharp. Now what I want to do is to modify this isosurface so that
>there is also a bump on the surface, kind of like a wart on the nose.
>Any ideas on how to do this would be appreciated.

The way I'd do it is:

First: Eliminate the Threshold value by subtracting 1 in the function {}
        function {P(x*2,y*(1.05-y/6),z*2) -1}

Then: Create a separate isosurface in the right location. It's much
easier to design this as a separate isosurface and then blob it onto the
nose later.
      isosurface {
        function {P(x*2,y*(1.05-y/6),z*2) -1}
        accuracy 0.001
        max_gradient 200
        contained_by{sphere{<0,0,0>,3}}
        pigment {rgbt <0,1,0>}
      }
      isosurface {
        function {P(x*4+1,y*4,z*4+2) -1}
        accuracy 0.001
        max_gradient 100
        contained_by{sphere{<0,0,0>,3}}
        pigment {rgbt <1,0,0>}
      }

Once that's looking reasonable: Multiply the two functions together and
subtract a small constant. The smaller the constant, the sharper will be
the blending between the two isosurfaces. You may need to increase
max_gradient.

#declare  P = function {x*x + y*y + z*z - 1}

#declare  P1 = function {P(x*2,y*(1.05-y/6),z*2) -1}
#declare  P2 = function {P(x*4+1,y*4,z*4+2) -1}

isosurface {
        function {P1(x,y,z)*P2(x,y,z) -0.03}
        accuracy 0.001
        max_gradient 5950
        contained_by{sphere{<0,0,0>,3}}
        pigment {rgbt <0,1,0>}
}

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: sumdumguy
Subject: Re: Isosurface help
Date: 22 Jan 2009 03:50:01
Message: <web.4978326bfb628f71dd43aa390@news.povray.org>
Mike Williams <nos### [at] econymdemoncouk> wrote:
> Wasn't it sumdumguy who wrote:
> >This is more or less a math question not syntax question. Still, I have killed
> >many hours on this and so maybe someone has an idea.
> >Say I have an isosurface:
> >
> >
> >#declare  P = function {x*x + y*y + z*z - 1}
> >
> >isosurface {
> >        function {P(x*2,y*(1.05-y/6),z*2)}
> >        threshold 1
> >        accuracy 0.001
> >        max_gradient 200
> >        contained_by{sphere{<0,0,0>,3}}
> >        pigment {rgbt <0,1,0>}
> >}
> >
> >This gives a stretched sphere where one side is squashed and the other
> >is more sharp. Now what I want to do is to modify this isosurface so that
> >there is also a bump on the surface, kind of like a wart on the nose.
> >Any ideas on how to do this would be appreciated.
>
> The way I'd do it is:
>
> First: Eliminate the Threshold value by subtracting 1 in the function {}
>         function {P(x*2,y*(1.05-y/6),z*2) -1}
>
> Then: Create a separate isosurface in the right location. It's much
> easier to design this as a separate isosurface and then blob it onto the
> nose later.
>       isosurface {
>         function {P(x*2,y*(1.05-y/6),z*2) -1}
>         accuracy 0.001
>         max_gradient 200
>         contained_by{sphere{<0,0,0>,3}}
>         pigment {rgbt <0,1,0>}
>       }
>       isosurface {
>         function {P(x*4+1,y*4,z*4+2) -1}
>         accuracy 0.001
>         max_gradient 100
>         contained_by{sphere{<0,0,0>,3}}
>         pigment {rgbt <1,0,0>}
>       }
>
> Once that's looking reasonable: Multiply the two functions together and
> subtract a small constant. The smaller the constant, the sharper will be
> the blending between the two isosurfaces. You may need to increase
> max_gradient.
>
> #declare  P = function {x*x + y*y + z*z - 1}
>
> #declare  P1 = function {P(x*2,y*(1.05-y/6),z*2) -1}
> #declare  P2 = function {P(x*4+1,y*4,z*4+2) -1}
>
> isosurface {
>         function {P1(x,y,z)*P2(x,y,z) -0.03}
>         accuracy 0.001
>         max_gradient 5950
>         contained_by{sphere{<0,0,0>,3}}
>         pigment {rgbt <0,1,0>}
> }
>
> --
> Mike Williams
> Gentleman of Leisure

Ah, so it seems I have the master's attention. So before going any further, many
thanks for your isosurface tutorial, it has been a terrific resource.

Now I tried what you have suggested before and got very weird results. Your
reply here has helped me understand where the problem was. You see, I was
really trying to do something like so:

function {P1(x,y,z)*P2(x,y,z)+f_noise3d(x*10, y*10, z*10)*0.3-0.03}

and when I add noise (values straight from the tutorial here, it creates a
problem: the joint shape partly disappears.
And I do not think it has to do with max_gradient. Rather it seems to be due to
the noise function going above threshold. Any suggestions for making this shape
wrinkly?


Post a reply to this message

From: Kenneth
Subject: Re: Isosurface help
Date: 22 Jan 2009 17:00:01
Message: <web.4978eb31fb628f71f50167bc0@news.povray.org>
Here's another version, using the isosurface 'smooth transits' idea at
"2.3.3.3.6 Combining isosurface functions" in the docs.  I also came up with a
'wrinkly' function--*trying* to get the look of wrinkly, sagging skin--but it
probably looks more like melted ice cream.  Oh well!

The max_gradient probably isn't high enough, but looks OK as-is.

Ken W.

----------

#declare  P = function {x*x + y*y + z*z - 1}

#declare  P1 = function {P(x*2,y*(1.05-y/6),z*2)}
#declare  P2 = function {P(x*4+1,y*4,z*4+2)}

// I like to specify my own color_map for pigment functions, for more
// control; the default ones look odd sometimes.
#declare my_color_map_1 =
color_map{
 [0.0 rgb 0]
 [1.0 rgb 1]
 }

#declare wrinkly_function =
function{
 pigment{
  spotted
  scale .2*<1,.1,1>
  sine_wave
  color_map {my_color_map_1}

  scale 4
  warp{turbulence .18*<1,1,1> omega .1}
  scale 1/4

  scale 10
  warp{turbulence .18*<.5,1,1> omega .1}
  scale 1/10

  scale .7*<.5,2,1>
  }
 }

isosurface {
        function {
        (1 + .01)
 - pow(.01,P1(x,y,z)*1)
 - pow(.01,P2(x,y,z)*1)
 + wrinkly_function(x,y,z).gray*.23
                 }

        accuracy 0.001
        max_gradient 50
        contained_by{sphere{<0,0,0>,1.2}}
        pigment {rgbt <0,1,0>}

        scale 2.5
           }


Post a reply to this message

From: Mike Williams
Subject: Re: Isosurface help
Date: 23 Jan 2009 00:00:03
Message: <etYhN+DcyUeJFwvF@econym.demon.co.uk>
Wasn't it sumdumguy who wrote:
>Mike Williams <nos### [at] econymdemoncouk> wrote:
>> Wasn't it sumdumguy who wrote:
>> >This is more or less a math question not syntax question. Still, I 
>> >have killed
>> >many hours on this and so maybe someone has an idea.
>> >Say I have an isosurface:
>> >
>> >
>> >#declare  P = function {x*x + y*y + z*z - 1}
>> >
>> >isosurface {
>> >        function {P(x*2,y*(1.05-y/6),z*2)}
>> >        threshold 1
>> >        accuracy 0.001
>> >        max_gradient 200
>> >        contained_by{sphere{<0,0,0>,3}}
>> >        pigment {rgbt <0,1,0>}
>> >}
>> >
>> >This gives a stretched sphere where one side is squashed and the other
>> >is more sharp. Now what I want to do is to modify this isosurface so that
>> >there is also a bump on the surface, kind of like a wart on the nose.
>> >Any ideas on how to do this would be appreciated.
>>
>> The way I'd do it is:
>>
>> First: Eliminate the Threshold value by subtracting 1 in the function {}
>>         function {P(x*2,y*(1.05-y/6),z*2) -1}
>>
>> Then: Create a separate isosurface in the right location. It's much
>> easier to design this as a separate isosurface and then blob it onto the
>> nose later.
>>       isosurface {
>>         function {P(x*2,y*(1.05-y/6),z*2) -1}
>>         accuracy 0.001
>>         max_gradient 200
>>         contained_by{sphere{<0,0,0>,3}}
>>         pigment {rgbt <0,1,0>}
>>       }
>>       isosurface {
>>         function {P(x*4+1,y*4,z*4+2) -1}
>>         accuracy 0.001
>>         max_gradient 100
>>         contained_by{sphere{<0,0,0>,3}}
>>         pigment {rgbt <1,0,0>}
>>       }
>>
>> Once that's looking reasonable: Multiply the two functions together and
>> subtract a small constant. The smaller the constant, the sharper will be
>> the blending between the two isosurfaces. You may need to increase
>> max_gradient.
>>
>> #declare  P = function {x*x + y*y + z*z - 1}
>>
>> #declare  P1 = function {P(x*2,y*(1.05-y/6),z*2) -1}
>> #declare  P2 = function {P(x*4+1,y*4,z*4+2) -1}
>>
>> isosurface {
>>         function {P1(x,y,z)*P2(x,y,z) -0.03}
>>         accuracy 0.001
>>         max_gradient 5950
>>         contained_by{sphere{<0,0,0>,3}}
>>         pigment {rgbt <0,1,0>}
>> }
>>
>> --
>> Mike Williams
>> Gentleman of Leisure
>
>Ah, so it seems I have the master's attention. So before going any 
>further, many
>thanks for your isosurface tutorial, it has been a terrific resource.
>
>Now I tried what you have suggested before and got very weird results. Your
>reply here has helped me understand where the problem was. You see, I was
>really trying to do something like so:
>
>function {P1(x,y,z)*P2(x,y,z)+f_noise3d(x*10, y*10, z*10)*0.3-0.03}
>
>and when I add noise (values straight from the tutorial here, it creates a
>problem: the joint shape partly disappears.
>And I do not think it has to do with max_gradient. Rather it seems to be due to
>the noise function going above threshold. Any suggestions for making this shape
>wrinkly?

Going this route, you have to apply the noise to the individual 
functions, not to the smoothness parameter:

#declare  P = function {x*x + y*y + z*z - 1}
#declare  N = function {f_noise3d(x*10, y*10, z*10)*0.3}

#declare  P1 = function {P(x*2,y*(1.05-y/6),z*2) -1 + N(x,y,z)}
#declare  P2 = function {P(x*4+1,y*4,z*4+2) -1 + N(x,y,z)}

isosurface {
         function {P1(x,y,z)*P2(x,y,z) -0.03}

This also allows for the possibility of having different wrinkles on the 
wart.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Kenneth
Subject: Re: Isosurface help
Date: 23 Jan 2009 10:30:01
Message: <web.4979e179fb628f71f50167bc0@news.povray.org>
Mike Williams <nos### [at] econymdemoncouk> wrote:

> First: Eliminate the Threshold value by subtracting 1 in the function {}
>         function {P(x*2,y*(1.05-y/6),z*2) -1}
>

Hi, Mike...

I was wondering about the reason for that, in functions P1 and P2. I see that
it's a kind of alternate way to create 'smoothe transits' between the two
spheres; but I'm curious if it has some added benefit that the docs' version
doesn't (speaking from sheer lack of understanding on my part.) The docs'
version produces a final composite object that does look a bit different from
yours--a smaller main sphere--but I can adjust that by making its radius
larger. Can you clue me in on why you've used an alternate technique? I'm most
curious! :-)

While we're on this topic: Something else I don't quite understand is why
*either* technique requires such a high max_gradient, when the resulting object
is just a smooth shape with no *apparent* sharp indents or other
difficult-to-evaluate slopes.

And would max_gradient's 'evaluate' be better to use on such composite
functions?

BTW, I too have learned *much* from your tutorials; what a great resource!

Ken W.


Post a reply to this message

From: Mike Williams
Subject: Re: Isosurface help
Date: 23 Jan 2009 12:20:06
Message: <Qm8SPnCMqfeJFwfd@econym.demon.co.uk>
Wasn't it Kenneth who wrote:
>Mike Williams <nos### [at] econymdemoncouk> wrote:
>
>> First: Eliminate the Threshold value by subtracting 1 in the function {}
>>         function {P(x*2,y*(1.05-y/6),z*2) -1}
>>
>
>Hi, Mike...
>
>I was wondering about the reason for that, in functions P1 and P2. I see that
>it's a kind of alternate way to create 'smoothe transits' between the two
>spheres; but I'm curious if it has some added benefit that the docs' version
>doesn't (speaking from sheer lack of understanding on my part.) The docs'
>version produces a final composite object that does look a bit different from
>yours--a smaller main sphere--but I can adjust that by making its radius
>larger. Can you clue me in on why you've used an alternate technique? I'm most
>curious! :-)

Eliminating threshold doesn't have any effect on the geometry, it just
makes the maths easier.

The surface exists at all points where f(x,y,z) = threshold. So
   function {P(x*2,y*(1.05-y/6),z*2)}
   threshold 1
is exactly the same as
   function {P(x*2,y*(1.05-y/6),z*2) -1}
   threshold 0
but now we can handle functions that are complicated expressions of P()
without also having to have complicated expressions of the threshold
value.

>While we're on this topic: Something else I don't quite understand is why
>*either* technique requires such a high max_gradient, when the resulting object
>is just a smooth shape with no *apparent* sharp indents or other
>difficult-to-evaluate slopes.

It's not the sharpness of the surface, but the rate of change of
function that causes the max_gradient requirement. For example
  function {x*x + y*y + z*z - 1}
and
  function {x*x*x*x + y*y*y*y + z*z*z*z - 1}
produce identical surfaces, but the values of the second one rise more
steeply, so there's a high max_gradient.

>And would max_gradient's 'evaluate' be better to use on such composite
>functions?

Probably. I never mastered evaluate.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: clipka
Subject: Re: Isosurface help
Date: 23 Jan 2009 12:55:00
Message: <web.497a0441fb628f71bdc576310@news.povray.org>
Mike Williams <nos### [at] econymdemoncouk> wrote:
> It's not the sharpness of the surface, but the rate of change of
> function that causes the max_gradient requirement. For example
>   function {x*x + y*y + z*z - 1}
> and
>   function {x*x*x*x + y*y*y*y + z*z*z*z - 1}
> produce identical surfaces, but the values of the second one rise more
> steeply, so there's a high max_gradient.

Are you sure you're correct on this one (I mean, in details)?

I would assume that as (x+y+z-1) gives different results than (x^2+y^2+z^2-1)
(the former is a plane, while the latter is a sphere), so would (x^4+y^4+z^4-1)
(some... quartic? Never tried it out)

I think
    function {500*x*x + 500*y*y + 500*z*z - 500}
comes closer to match the point you're making.


Post a reply to this message

From: Warp
Subject: Re: Isosurface help
Date: 23 Jan 2009 13:07:12
Message: <497a0750@news.povray.org>
clipka <nomail@nomail> wrote:
> I would assume that as (x+y+z-1) gives different results than (x^2+y^2+z^2-1)
> (the former is a plane, while the latter is a sphere), so would (x^4+y^4+z^4-1)
> (some... quartic? Never tried it out)

  I think it produces something which looks like a rounded cube, ie. like
a superellipsoid with both parameters the same (like <.1, .1> or whatever).

-- 
                                                          - Warp


Post a reply to this message

From: Kenneth
Subject: Re: Isosurface help
Date: 23 Jan 2009 14:15:00
Message: <web.497a1630fb628f71f50167bc0@news.povray.org>
Mike Williams <nos### [at] econymdemoncouk> wrote:

> Eliminating threshold doesn't have any effect on the geometry, it just
> makes the maths easier.

Actually, in the case of the two aforementioned 'methods', the final object does
look a bit different from one to the other--the 'wart' protrudes further using
the docs' method, or else the main sphere has been decreased in size. Not sure
which, or why. Not a big deal, of course.
>
> The surface exists at all points where f(x,y,z) = threshold. So
>    function {P(x*2,y*(1.05-y/6),z*2)}
>    threshold 1
> is exactly the same as
>    function {P(x*2,y*(1.05-y/6),z*2) -1}
>    threshold 0

OK, got that. Thanks. I never understood that 'til now, although it's probably
in your tutorials and I just glossed over that part.  (Heretofore, I've had a
tendency to just leave threshold at it's default value, without even thinking;
it's rather 'unexplored territory' that I need to learn more about.)

> It's not the sharpness of the surface, but the rate of change of
> function that causes the max_gradient requirement...

Oh! I do see the point you're making. A new discovery for me. Thanks for
explaining!

Ken


Post a reply to this message

Goto Latest 10 Messages Next 2 Messages >>>

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