|
![](/i/fill.gif) |
> 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
|
![](/i/fill.gif) |