POV-Ray : Newsgroups : povray.binaries.images : isosurface problem Server Time
5 Nov 2024 22:24:12 EST (-0500)
  isosurface problem (Message 1 to 8 of 8)  
From: Bill Pragnell
Subject: isosurface problem
Date: 11 May 2005 11:50:01
Message: <web.428227ff92ff4ee0731f01d10@news.povray.org>
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:

// rounded tetrahedron function
// a is 'radius' of outcube
// b is radius of edge curves
#declare fn_rounded_tetra = function(x, y, z, a, b) {
  min( // backside
       max( (sqrt(0.5*(x+y)*(x+y) + (z-a)*(z-a)) - b),
            (-x+y-2*a),
            (x-y-2*a) ),
       // frontside
       max( (sqrt(0.5*(x-y)*(x-y) + (z+a)*(z+a)) - b),
            (x+y-2*a),
            (-x-y-2*a) ),
       // topside
       max( (sqrt(0.5*(x+z)*(x+z) + (y-a)*(y-a)) - b),
            (-x+z-2*a),
            (x-z-2*a) ),
       // bottomside
       max( (sqrt(0.5*(x-z)*(x-z) + (y+a)*(y+a)) - b),
            (-x-z-2*a),
            (x+z-2*a) ),
       // leftside
       max( (sqrt(0.5*(y-z)*(y-z) + (x+a)*(x+a)) - b),
            (y+z-2*a),
            (-y-z-2*a) ),
       // rightside
       max( (sqrt(0.5*(y+z)*(y+z) + (x-a)*(x-a)) - b),
            (y-z-2*a),
            (-y+z-2*a) ),
       // vertices
       f_sphere(x+a, y-a, z-a, b),
       f_sphere(x-a, y-a, z+a, b),
       f_sphere(x+a, y+a, z+a, b),
       f_sphere(x-a, y+a, z-a, b),
       // plane faces
       max( (x+y+z -( (a*sin(radians(f_f)/2)+b) / sin(radians(f_f)/2) )),
            (-x+y-z-( (a*sin(radians(f_f)/2)+b) / sin(radians(f_f)/2) )),
            (x-y-z -( (a*sin(radians(f_f)/2)+b) / sin(radians(f_f)/2) )),
            (-x-y+z-( (a*sin(radians(f_f)/2)+b) / sin(radians(f_f)/2) )),
            (y -  (a+b*cos(radians((180-f_f))/2))),
            (-y - (a+b*cos(radians((180-f_f))/2))),
            (x -  (a+b*cos(radians((180-f_f))/2))),
            (-x - (a+b*cos(radians((180-f_f))/2))),
            (z -  (a+b*cos(radians((180-f_f))/2))),
            (-z - (a+b*cos(radians((180-f_f))/2))),
            (-x+y+z - 2*(sqrt(3*a*a) + b*cos(radians((180-f_e))/2)) ),
            (x+y-z  - 2*(sqrt(3*a*a) + b*cos(radians((180-f_e))/2)) ),
            (x-y+z  - 2*(sqrt(3*a*a) + b*cos(radians((180-f_e))/2)) ),
            (-x-y-z - 2*(sqrt(3*a*a) + b*cos(radians((180-f_e))/2)) ) ) ) }

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


Post a reply to this message


Attachments:
Download 'tetra2.jpg' (25 KB)

Preview of image 'tetra2.jpg'
tetra2.jpg


 

From: Bill Pragnell
Subject: Re: isosurface problem
Date: 11 May 2005 11:55:01
Message: <web.42822a3875855243731f01d10@news.povray.org>
Couldn't post two pics. Heres the secon pic with the offending glitch.
Bill


Post a reply to this message


Attachments:
Download 'tetra1.jpg' (46 KB)

Preview of image 'tetra1.jpg'
tetra1.jpg


 

From: Christoph Hormann
Subject: Re: isosurface problem
Date: 11 May 2005 13:50:01
Message: <d5tgho$86b$1@chho.imagico.de>
Bill Pragnell wrote:
> 
> 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?

For a well working displacement you need your base function to be a 
correct distance function of the shape you want to displace - as Mike 
pointed out your function isn't.

You could for example use the IsoCSG library:

http://www.tu-bs.de/~y0013390/pov/ic/index.html

and create a merge of three triangles which would meet this condition (i 
think so - have not tested actually). Note using the builtin triangle 
function in MegaPOV would make this faster.

Christoph

-- 
POV-Ray tutorials, include files, Sim-POV,
HCR-Edit and more: http://www.tu-bs.de/~y0013390/
Last updated 03 May. 2005 _____./\/^>_*_<^\/\.______


Post a reply to this message

From: Mike Williams
Subject: Re: isosurface problem
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

From: James Buddenhagen
Subject: Re: isosurface problem
Date: 11 May 2005 16:28:55
Message: <42826b07$1@news.povray.org>
"Mike Williams" <nos### [at] econymdemoncouk> wrote in message
news:aDeV$GAGakgCFwx2@econym.demon.co.uk...

[...snip...]

> // 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
> }

Interesting approach.  If I calculate correctly we need
0 <= b <= a^4 and now the object (without crack and agate)
is contained by box {-c,c} where c = sqrt(a*a - sqrt(b)).
Note that this approaches 0 (i.e. a single point, the
origin) as b approaches a^4.

I have not yet used isosurfaces but I was surprized that
you set it up so that the function is negative inside
the surface and positive outside the surface.  When
I tried your code with the negative of your function I
got the bounding box, not your surface.  That really
surprised me.  Is that a bug or am I missing something?
--
Jim Buddenhagen


Post a reply to this message

From: Cousin Ricky
Subject: Re: isosurface problem
Date: 11 May 2005 20:35:00
Message: <web.4282a3fd75855243755fa2580@news.povray.org>
"James Buddenhagen" <jbu### [at] REMOVEtexasnet> wrote:
> I have not yet used isosurfaces but I was surprized that
> you set it up so that the function is negative inside
> the surface and positive outside the surface.  When
> I tried your code with the negative of your function I
> got the bounding box, not your surface.  That really
> surprised me.  Is that a bug or am I missing something?

You are missing something.  This is exactly the way POV-Ray isosurfaces are
supposed to work.  You may question the judgement of the POV team for
arranging it this way, but that's the decision that they made.

I've occasionally run into a bona fide bug, but my first reaction is to
assume that i missed something.  The POV team has been doing this for a
long time, so i presume that they know what they're doing.  Sure enough,
when i read the message window or take a second look at the documentation,
i almost always find the explanation staring back at me.

One thing that took me by surprise is that my first few tries rendered with
numerous artifacts and huge chunks missing from the objects.  Quite scary.
When this happens to you (and it will), you can save the trouble of
reporting this "bug" by checking the messages; you will find that POV-Ray
has already suspected that you didn't get what you wanted, and issued a
warning with a suggested fix.


Post a reply to this message

From: Bill Pragnell
Subject: Re: isosurface problem
Date: 12 May 2005 06:40:00
Message: <web.4283321175855243731f01d10@news.povray.org>
> I don't think that approach is ever going to work. [See my previous reply
> for my reasoning]
Yes, I can see what you mean. I should have thought of that.

> 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.
That's brilliant! It would never have occurred to me to blob planes together
like that. Really elegant. The difference in rounding effect is not a
problem - the result of your code is actually better (i.e. more realistic)
than what I would have ended up with. Yours renders faster than mine, too!
I need it a little craggier than your demo but I can play with that myself.

Just goes to show - if it's complicated and doesn't work, you're probably
pushing a boulder up the wrong mountain.

And you feel extra stupid if the boulder turns out to be tetrahedral.


Much thanks, and others' suggestions too.

Bill


Post a reply to this message

From: Alf Peake
Subject: Re: isosurface problem
Date: 12 May 2005 09:16:11
Message: <4283571b@news.povray.org>
Hi

That looks like a problem I had with an isosurface rounded cylinder
macro. No problem until I added a random wood pigment function and
tried to auto-scale it to add to the isosurface.

I linked to this image, which is dated 8 Jan 2003, when I yelled for
help on p.g or p.a-u but can't find the thread now. The answer is on 
this server somewhere ;)

Alf


Post a reply to this message


Attachments:
Download 'roundcyl.jpg' (13 KB)

Preview of image 'roundcyl.jpg'
roundcyl.jpg


 

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