POV-Ray : Newsgroups : povray.binaries.images : Isosurface woes Server Time
1 Nov 2024 10:18:15 EDT (-0400)
  Isosurface woes (Message 1 to 10 of 15)  
Goto Latest 10 Messages Next 5 Messages >>>
From: jceddy
Subject: Isosurface woes
Date: 12 Jul 2013 09:20:01
Message: <web.51e002288eb11ad2314aa6840@news.povray.org>
So, I have the following macro that generates a rounded cylinder isosurface with
a noise/pigment subtracted from it:

#declare fn_CracklePigment = function {
    pigment {
        crackle
        pigment_map {
          [0.1 color rgb 1]
          [0.2 color rgb 0]
        }
    }
}

#declare fn_Cylinder = function(_x, _y, _z, _rad, _len) {
  max(sqrt(pow(_x,2) + pow(_z,2)) - _rad, f_rounded_box(_x, _y, _z, 0, _rad,
_len/2, _rad))
}

#macro RoundCylinder(inner, outer, length)
  #if(use_iso)
    isosurface {
      function {
        min(
          min(
            f_torus(x, y - (length/2-outer), z, inner-outer, outer),
            fn_Cylinder(x, y, z, inner, length-2*outer)
          ),
          min(
            fn_Cylinder(x, y, z, inner-outer, length),
            f_torus(x, y + (length/2-outer), z, inner-outer, outer)
          )
        ) + fn_CracklePigment(x, y, z).gray/10
      }
      contained_by { box { <-10, -length/2, -10>, <10, length/2, 10> } }  //
container shape
      accuracy 0.001                      // accuracy of calculation [0.001]
      max_gradient 4                      // maximum gradient the function can
have [1.1]

      texture {
        crackle
        texture_map {
          [0.1 pigment { color rgb <1, 0, 0> } finish { ambient 1.0 }]
          [0.2 pigment { color rgb <0, 0, 0> } ]
        }
      }
    }
  #else
    union {
      torus { inner-outer, outer translate <0, length/2-outer, 0> }
      cylinder { <0, -length/2+outer, 0>, <0, length/2-outer, 0>, inner }
      cylinder { <0, -length/2, 0>, <0, length/2, 0>, inner-outer }
      torus { inner-outer, outer translate <0, -(length/2)+outer, 0> }

      texture {
        crackle
        texture_map {
          [0.1 pigment { color rgb <1, 0, 0> } finish { ambient 1.0 }]
          [0.2 pigment { color rgb <0, 0, 0> } ]
        }
      }
    }
  #end
#end

The issue is that as soon as I add in the "+ fn_CracklePigment(x, y, z).gray/10"
to the isosurface function, the generated image gets all funky...basically it
goes from being a rounded cylinder to two cool-looking crackle torii with some
black junk between...when I'm expecting a cool looking crackle rounded cylinder.

Any ideas?

I'm trying to create some shapes that kind look like cracked volcanic rock
glowing from within that I will then compose together into a kind of golem
creature.

On the left is an image generated without the crackle pigment modifier to the
isosurface function. On the right is the image generated from the code above
as-is.


Post a reply to this message


Attachments:
Download 'golem01a.jpg' (95 KB)

Preview of image 'golem01a.jpg'
golem01a.jpg


 

From: BertvdB
Subject: Re: Isosurface woes
Date: 12 Jul 2013 16:30:01
Message: <web.51e06646b644a79dd25d21bf0@news.povray.org>
Try to subtract the crackle from onely one or two parameters of the cylinder
function and maybe a smaller factor divide by 100 or so


Post a reply to this message

From: BertvdB
Subject: Re: Isosurface woes
Date: 12 Jul 2013 16:30:02
Message: <web.51e066fab644a79dd25d21bf0@news.povray.org>
And subtract the crackle not add it (-fn)


Post a reply to this message

From: Fractracer
Subject: Re: Isosurface woes
Date: 12 Jul 2013 17:00:01
Message: <web.51e06e03b644a79dbba32da90@news.povray.org>
I have tried your scene with RoundCylinder(1.0, 1.6, 4) and I've got an image
like follow:


Post a reply to this message

From: Fractracer
Subject: Re: Isosurface woes
Date: 12 Jul 2013 17:25:01
Message: <web.51e073b3b644a79dbba32da90@news.povray.org>
"Fractracer" <lg.### [at] gmailcom> wrote:
> I have tried your scene with RoundCylinder(1.0, 1.6, 4) and I've got an image
> like follow:

OOPS! Sorry i've missed the picture, here it is.
Also, if you substract fn_crackle, you get a sponge-like form.
Your macro is amazing, tring modified some params or funcs to obtain various
rocks.


Post a reply to this message


Attachments:
Download 'iso_crackle.jpg' (48 KB)

Preview of image 'iso_crackle.jpg'
iso_crackle.jpg


 

From: s day
Subject: Re: Isosurface woes
Date: 12 Jul 2013 17:25:02
Message: <web.51e073eeb644a79d5bfe13270@news.povray.org>
"jceddy" <jce### [at] gmailcom> wrote:

> Any ideas?
>

I adjusted the crackle function (reversed the colours) then subtracted this from
the cylinder instead of adding it (see below) does the attached look like what
you were after?

Sean

#declare fn_CracklePigment = function {
    pigment {
        crackle
        pigment_map {
          [0.1 color rgb 0]
          [0.2 color rgb 1]
        }
    }
}

#declare fn_Cylinder = function(_x, _y, _z, _rad, _len) {
  max(sqrt(pow(_x,2) + pow(_z,2)) - _rad, f_rounded_box(_x, _y, _z, 0, _rad,
_len/2, _rad))
}

#macro RoundCylinder(inner, outer, length)
  #if(use_iso)
    isosurface {
      function {
        min(
          min(
            f_torus(x, y - (length/2-outer), z, inner-outer, outer),
            fn_Cylinder(x, y, z, inner, length-2*outer)
          ),
          min(
            fn_Cylinder(x, y, z, inner-outer, length),
            f_torus(x, y + (length/2-outer), z, inner-outer, outer)
          )
        ) - fn_CracklePigment(x, y, z).gray/10
      }
      contained_by { box { <-10, -length/2, -10>, <10, length/2, 10> } }
//container shape
      accuracy 0.001                      // accuracy of calculation [0.001]
      max_gradient 4                      // maximum gradient the function
canhave [1.1]

      texture {
        crackle
        texture_map {
          [0.1 pigment { color rgb <1, 0, 0> } finish { ambient 1.0 }]
          [0.2 pigment { color rgb <0, 0, 0> } ]
        }
      }
    }
  #else
    union {
      torus { inner-outer, outer translate <0, length/2-outer, 0> }
      cylinder { <0, -length/2+outer, 0>, <0, length/2-outer, 0>, inner }
      cylinder { <0, -length/2, 0>, <0, length/2, 0>, inner-outer }
      torus { inner-outer, outer translate <0, -(length/2)+outer, 0> }

      texture {
        crackle
        texture_map {
          [0.1 pigment { color rgb <1, 0, 0> } finish { ambient 1.0 }]
          [0.2 pigment { color rgb <0, 1, 0> } finish { ambient 1 }]
        }
      }
    }
  #end
#end

object { RoundCylinder(3, 0.2, 5) }


Post a reply to this message


Attachments:
Download 'c.png' (36 KB)

Preview of image 'c.png'
c.png


 

From: William F Pokorny
Subject: Re: Isosurface woes
Date: 13 Jul 2013 08:27:03
Message: <51e14797$1@news.povray.org>
On 07/12/2013 09:18 AM, jceddy wrote:
>........

Where you are intersecting the infinite cylinder function with the built 
in rounded box function, I would recommend avoiding 0 rounding for the 
corners. In my experience f_rounded_box performance is an order of 
magnitude or more faster when even a little (0.02) rounding is specified.

You'd need to adjust the intersection f_rounded_box x and z scaling by 
adding the rounding used else the rounded corners show up in the 
resulting shape.

max(sqrt(pow(_x,2) + pow(_z,2)) - _rad, \
     f_rounded_box(_x, _y, _z, 0, _rad+rd,_len/2, _rad+rd))

Thinking aloud: I'm guessing others responding recommended subtracting 
the crackle function instead of adding because in subtracting any 
function returning values >=0, the shape is made larger. In other words, 
using subtraction here removes any chance the addition of the crackle 
shrinks the shape, or parts of it, to nothing.

Bill P.


Post a reply to this message

From: Alain
Subject: Re: Isosurface woes
Date: 13 Jul 2013 16:34:24
Message: <51e1b9d0$1@news.povray.org>

> So, I have the following macro that generates a rounded cylinder isosurface with
> a noise/pigment subtracted from it:
>
> #declare fn_CracklePigment = function {
>      pigment {
>          crackle
>          pigment_map {
>            [0.1 color rgb 1]
>            [0.2 color rgb 0]
>          }
>      }
> }
>
> #declare fn_Cylinder = function(_x, _y, _z, _rad, _len) {
>    max(sqrt(pow(_x,2) + pow(_z,2)) - _rad, f_rounded_box(_x, _y, _z, 0, _rad,
> _len/2, _rad))
> }
>
> #macro RoundCylinder(inner, outer, length)
>    #if(use_iso)
>      isosurface {
>        function {
>          min(
>            min(
>              f_torus(x, y - (length/2-outer), z, inner-outer, outer),
>              fn_Cylinder(x, y, z, inner, length-2*outer)
>            ),
>            min(
>              fn_Cylinder(x, y, z, inner-outer, length),
>              f_torus(x, y + (length/2-outer), z, inner-outer, outer)
>            )
>          ) + fn_CracklePigment(x, y, z).gray/10
>        }
>        contained_by { box { <-10, -length/2, -10>, <10, length/2, 10> } }  //
> container shape
>        accuracy 0.001                      // accuracy of calculation [0.001]
>        max_gradient 4                      // maximum gradient the function can
> have [1.1]
>
>        texture {
>          crackle
>          texture_map {
>            [0.1 pigment { color rgb <1, 0, 0> } finish { ambient 1.0 }]
>            [0.2 pigment { color rgb <0, 0, 0> } ]
>          }
>        }
>      }
>    #else
>      union {
>        torus { inner-outer, outer translate <0, length/2-outer, 0> }
>        cylinder { <0, -length/2+outer, 0>, <0, length/2-outer, 0>, inner }
>        cylinder { <0, -length/2, 0>, <0, length/2, 0>, inner-outer }
>        torus { inner-outer, outer translate <0, -(length/2)+outer, 0> }
>
>        texture {
>          crackle
>          texture_map {
>            [0.1 pigment { color rgb <1, 0, 0> } finish { ambient 1.0 }]
>            [0.2 pigment { color rgb <0, 0, 0> } ]
>          }
>        }
>      }
>    #end
> #end
>

Check the messages, paying attention to the max_gradient found. Your 
max_gradient may be to low.

As have been said, try with a larger rounding radius.

Performance whise, as your crackle function is created in shades of 
gray, going from rgb 0 to rgb 1, you can safely use .red, .green or 
.blue and get exactly the same result, but get it faster.

.red, .green and .blue simply return the value of a single channel. In 
your case, they are all the same.
.gray evaluate all 3 colour channels and perform a ponderated average. 
As the 3 channels are the same, that average is exactly the value of any 
one channels.

For your base cylinder, you can:
#include "functions.inc"
Then, use:
function { -f_superellipsoid(x,y,z, 0.1, 1) + fn_CracklePigment(x, y, 
z).red/10 }

With this function, setting the last parameter to 1 gives a rounded 
cylinder.

Or make your actual function a little simpler:
     isosurface {
       function {
         min(
             f_torus(x, y - (length/2-outer), z, inner-outer, outer),
             fn_Cylinder(x, y, z, inner, length-2*outer)
             fn_Cylinder(x, y, z, inner-outer, length),
             f_torus(x, y + (length/2-outer), z, inner-outer, outer)
         ) + fn_CracklePigment(x, y, z).red/10
       }


min and max are not limited to only 2 parameters.
The are described as max(A,B,...) and min(A,B,...) meaning they can take 
an arbitrary number of parameters larger than 1.



Alain


Post a reply to this message

From: jceddy
Subject: Re: Isosurface woes
Date: 15 Jul 2013 16:35:00
Message: <web.51e45beab644a79d314aa6840@news.povray.org>
Thanks for the help, guys.

I changed the component from .gray to .red. I also found that I was able to
decrease the max_gradient a bit, and now the image renders in about half the
time it was previously.

Also simplified the max() to take 4 args instead of nesting.

I modified the iso to subtract the inverse of the crackle pigment, as well...I
realized belatedly that this actually works better for when I'm composing it
into the object it fits into, since I know the result takes up *at least* the
space that the original rounded cylinder did. I did have to increase the size of
the bounding box a bit so stuff sticking out on the ends of the cylinder don't
get cut off.

I avoided using fn_superellipsoid because it didn't give me quite the control I
wanted.

I attached an image of the working cylinder.

I'll try to remember to post an image (at least a rough draft) of the thing I'm
working on that will use it.

I think this could be pretty cool in an image using radiosity to make the red
really glow, but haven't had the patience to do any kind of test render yet.


Post a reply to this message


Attachments:
Download 'golem01.jpg' (62 KB)

Preview of image 'golem01.jpg'
golem01.jpg


 

From: jceddy
Subject: Re: Isosurface woes
Date: 15 Jul 2013 17:55:01
Message: <web.51e46e96b644a79d314aa6840@news.povray.org>
I've been using the robot from Cod3Monk3y's POV Planet for testing various
materials.  Here's an image incorporating the lava-rock cylinder (the big
spheres are still just plain textured spheres). The metal part is a copper with
patina I've been working on, but is still too shiny on the clean parts.

Here's the test image.


Post a reply to this message


Attachments:
Download 'golem01.jpg' (85 KB)

Preview of image 'golem01.jpg'
golem01.jpg


 

Goto Latest 10 Messages Next 5 Messages >>>

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