|
![](/i/fill.gif) |
Mike Williams <nos### [at] econym demon co uk> wrote:
> Wasn't it sumdumguy who wrote:
> >Mike Williams <nos### [at] econym demon co uk> 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
Thanks, that works beautifully.
Post a reply to this message
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
Warp wrote:
> 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).
>
That's correct. What he should have written to still get a sphere is:
(x^2 + y^2 + z^2)^2 - 1 = 0
or
x^4 + 2 x^2 y^2 + 2 z^2 x^2 + y^4 + 2 y^2 z^2 + z^4 - 1 = 0
Note x^4 + y^4 + z^4 - 1 does not yield the sphere, but the rounded cube, as you note.
The difference terms are
2[ x^2 y^2 + y^2 z^2 + z^2 x^2 ]
So the two are coincident where only one of the three coordinates is non-zero, ie
along the principal axes. Everywhere else, omitting these terms requires a greater
value of x^4 + y^4 + z^4 to compensate... ie the object is drawn out to the corners.
He could also have written:
(x^2 + y^2 + z^2 - 1)^2 = 0
But since this never crosses zero, only tangentially touches it, I doubt the software
would be able to map the surface.
Dan
Post a reply to this message
|
![](/i/fill.gif) |