POV-Ray : Newsgroups : povray.binaries.images : Cracked Sphere (~41kbbu) : Re: Cracked Sphere (~41kbbu) Server Time
1 Oct 2024 05:18:29 EDT (-0400)
  Re: Cracked Sphere (~41kbbu)  
From: Mike Williams
Date: 13 Sep 2000 01:49:31
Message: <fTH8JAAnTxv5EwWM@econym.demon.co.uk>
Wasn't it Richard Dault who wrote:
>They are isosurfaces.  It's a marble function pattern removed from a sphere.
>That's why I'm surprised the crack doesn't appear on the inside.
>
>Here's a snippet of code:
>
>#declare ball = function { x*x + y*y + z*z - 2*2 }
>#declare crack = function {
>    pigment { marble turbulence .7
>      color_map {[0 rgb 1][.5 rgb 1][.5 rgb 0][.505 rgb 0][.505 rgb 1][1 rgb
>1]}
>      scale 4
>    }
>  }
>
>isosurface {
>  function {
>    ball(x,y,z)
>    - crack(x,y,z)
>  }
>  max_trace 3
>  method 2
>  accuracy 0.001
>  threshold 0
>  max_gradient 20
>  contained_by { sphere { 0 2.3 } }
>  texture { pigment { rgbf <.95,.95,1,.95> } finish { reflection .1
>roughness .001 specular .8 ambient 0 diffuse 0 } }
>  interior { ior 1.5 }
>}

There may be two things going on here:-

1. You're lying about the max_gradient value. In this case the max_gradient is
about 24. If you don't actually know the max_gradient value you should use
"eval" instead, otherwise the result will be incorrect.

2. This may be causing you to hit the contained by sphere. The crack()
function takes a value of 1 almost everywhere, and the ball() function takes
the value "R^2-4", where R is the distance from <0,0,0>. So the resulting
sphere ought to be given by "R^2-4-1 = 0", i.e. having radius sqrt(5), which
is about 2.236, so when you get the max_gradient right that ought to just be
OK.

Using "eval" and increasing a slightly larger contained_by sphere gives a
result with a crack that can be seen to just indent slightly.

3. The maximum depth of the crack ought to be obtained when crack() evaluates
to zero. I.e. when "R^2-4 = 0", i.e. when R=2. So the maximum possible depth
of the crack is 0.236 units. However, because the crack is so narrow, you will
almost never see down to this depth.

You could try increasing the depth of the crack by inverting the colour map,
like

  color_map {[0 rgb 0][.5 rgb 0][.5 rgb 1][.505 rgb 1][.505 rgb 0][1 rgb 0]}

and changing your main function to

  function { ball(x,y,z) + crack(x,y,z)*6 -1 }

*Adding* the inverted crack to the sphere. "crack()*5-1" takes the value "-1"
almost everywhere (thus retaining the overall sphere radius of sqrt(5)), but
now the maximum value of "crack()*5-1" is +4, which allows the crack to reach
down to where "R^4-4+4=0", which is right through the sphere.

Combining all those changes does produce a pair of sheet-like cracks that can
be seen to go right through the sphere. It's a bit slow though, and the
max_gradient shoots up to over 10000 for some reason.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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