POV-Ray : Newsgroups : povray.binaries.images : isosurface problem : Re: isosurface problem Server Time
8 Aug 2024 20:24:19 EDT (-0400)
  Re: isosurface problem  
From: Mike Williams
Date: 11 May 2005 13:53:32
Message: <aDeV$GAGakgCFwx2@econym.demon.co.uk>
Wasn't it Bill Pragnell who wrote:
>Right then, all you isosurface gurus out there: perhaps you can help me with
>this.
>
>Here's the problem. I'm trying to create a tetrahedral asteroid using an
>isosurface. I've written a function which comprises four spheres, six
>cylinders and a tetrahedron with its vertices and edges trimmed using a
>functional intersection, merged to produce a perfect rounded tetrahedron
>(first picture). I'm then boulderifying this base shape by adding crackle
>and agate pigment functions.
>
>No problem so far, I hear you say.
>
>However, there appears to be a mismatch between the planar faces and the
>curved edges which produces "fault lines" (second picture). I've tried
>upping accuracy and max_gradient to no avail, and I've tried adding /
>subtracting the pigment functions in various combinations - no good. Can
>anyone shed any light on this bizarre artefact?
>
>Source code, in case I'm being stupid:

I don't think that approach is ever going to work. [See my previous reply
for my reasoning]

What you can do however is take the four faces of a simple tetrahedron
and 'blob' them together to get a rounded effect.
[see <http://www.econym.demon.co.uk/isotut/combine.htm#blob> for function
'blobbing']

The rounded effect isn't the same as what you get with planes, cylinders
and spheres. The radius of curvature changes gradually rather than
suddenly changing from zero to b at a point near the edge. The faces are
not completely flat.

In order to get this to work, the size of "contained_by" box must be the
same as the 'radius' of the tetrahedron, otherwise you get "inside out
bits" from all the places that are "inside" an even number of planes.

Because the multiplied gradients are higher, the max_gradient becomes
unfortunately very large, and the pigment functions need to be made much
stronger.

Since there's now no "b", the bits that look like
 "sin(radians(f_f)/2)+b) / sin(radians(f_f)/2)"
evaluate to 1, which simplifies things a bit. Giving a complete scene
file that looks something like this:


#version 3.6;
global_settings {assumed_gamma 1.0}
camera {location  <0,0,-70> look_at <0,0,0> angle 30}
light_source {<-30, 100, -30> color rgb 1}
light_source {<0,0,-50> rgb 0.5}

#include "functions.inc" 
#include "colors.inc"

#declare fn_agate=function{pigment{agate}}
#declare fn_crack=function{pigment{crackle}}

// tetrahedron function
// a is 'radius' of outcube
// b is 'blob' strength
#declare fn_blobbed_tetra = function(x, y, z, a, b) {
        - ( x+y+z -a)
        * (-x+y-z -a)
        * ( x-y-z -a)
        * (-x-y+z -a)
        + b       
}

#declare Boulder = isosurface {
  function { fn_blobbed_tetra(x,y,z,10,250)
    + fn_agate(x/4,y/4,z/4).gray*0.3    *200
    - fn_crack(x/4,y/4,z/4).gray*0.75   *200
  }
  max_gradient 12030
  contained_by { box {-10, 10 } }
  pigment { color White } 
}

object {Boulder}


-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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