POV-Ray : Newsgroups : povray.binaries.images : smooth csg Server Time
1 Nov 2024 20:23:01 EDT (-0400)
  smooth csg (Message 1 to 10 of 12)  
Goto Latest 10 Messages Next 2 Messages >>>
From: Tek
Subject: smooth csg
Date: 1 Mar 2012 10:05:02
Message: <web.4f4f8f38237bc9d711277d9c0@news.povray.org>
Something I've been playing around with recently. Using isosurfaces and some
macros to make CSG with smoothing. I realise I'm not the first person to think
of this, but I thought my results were worth sharing.

This scene has a few shapes combined with a little smoothing, plus a moss
texture controlled by the same shapes but with more smoothing (so it finds the
nooks and crannies). Also the isosurface has cracks which are controlled by the
smoother pattern, so there's more cracks on the thinner edges.

I'll post the source some time soon, and will probably update my website to have
a few of my useful include files on it.

--
Tek
http://evilsuperbrain.com


Post a reply to this message


Attachments:
Download 'scsg_proximitypattern - copy.png' (754 KB)

Preview of image 'scsg_proximitypattern - copy.png'
scsg_proximitypattern - copy.png


 

From: clipka
Subject: Re: smooth csg
Date: 1 Mar 2012 11:01:54
Message: <4f4f9d72@news.povray.org>
Am 01.03.2012 16:01, schrieb Tek:
> Something I've been playing around with recently. Using isosurfaces and some
> macros to make CSG with smoothing. I realise I'm not the first person to think
> of this, but I thought my results were worth sharing.

Are you using a blob-style approach, or a classic CSG object smoothed by 
means of some magic "post-processing"?


Post a reply to this message

From: Tek
Subject: Re: smooth csg
Date: 1 Mar 2012 12:05:01
Message: <web.4f4fab67bc71efa911277d9c0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 01.03.2012 16:01, schrieb Tek:
> > Something I've been playing around with recently. Using isosurfaces and some
> > macros to make CSG with smoothing. I realise I'm not the first person to think
> > of this, but I thought my results were worth sharing.
>
> Are you using a blob-style approach, or a classic CSG object smoothed by
> means of some magic "post-processing"?

Essentially it's a blob-style approach, but with different smoothing amounts on
every CSG operation. So I can have a sharp edge where two soft-edged boxes meet,
or whatever. Though everything in this scene has the same amount of smoothness.


Post a reply to this message

From: Tek
Subject: Re: smooth csg
Date: 1 Mar 2012 13:15:01
Message: <web.4f4fbc9abc71efa911277d9c0@news.povray.org>
Here's another little thing I made using my smooth csg macros. I've always
wanted some way to make these kinds of sci-fi shapes, finally I've figured
something out! Albeit something which relies on isosurfaces and brute force, and
would have been completely impractical to render on my old PC.

The rocket exhaust is plain old CSG, no smoothing. Everything else is built from
cylinders using my smooth csg macros.


Post a reply to this message


Attachments:
Download 'scsg_scifi.png' (143 KB)

Preview of image 'scsg_scifi.png'
scsg_scifi.png


 

From: clipka
Subject: Re: smooth csg
Date: 2 Mar 2012 07:55:37
Message: <4f50c349$1@news.povray.org>
Am 01.03.2012 19:14, schrieb Tek:
> Here's another little thing I made using my smooth csg macros. I've always
> wanted some way to make these kinds of sci-fi shapes, finally I've figured
> something out! Albeit something which relies on isosurfaces and brute force, and
> would have been completely impractical to render on my old PC.
>
> The rocket exhaust is plain old CSG, no smoothing. Everything else is built from
> cylinders using my smooth csg macros.

You do care to share those macros, don't you? <drool>


Post a reply to this message

From: Tek
Subject: Re: smooth csg
Date: 2 Mar 2012 08:50:01
Message: <web.4f50cfc5bc71efa911277d9c0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 01.03.2012 19:14, schrieb Tek:
> > Here's another little thing I made using my smooth csg macros. I've always
> > wanted some way to make these kinds of sci-fi shapes, finally I've figured
> > something out! Albeit something which relies on isosurfaces and brute force, and
> > would have been completely impractical to render on my old PC.
> >
> > The rocket exhaust is plain old CSG, no smoothing. Everything else is built from
> > cylinders using my smooth csg macros.
>
> You do care to share those macros, don't you? <drool>

I just want to clean the code up a bit more and provide some example files and a
simple manual... I aim to release the source in a few days...


Post a reply to this message

From: Florian Siegmund
Subject: Re: smooth csg
Date: 3 Mar 2012 11:30:01
Message: <web.4f524634bc71efa997033c3c0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
>
> You do care to share those macros, don't you? <drool>

Hi folks!

I also wrote some function macros for building smooth csg objects with
isosurfaces some time ago. The advatage of these macros in opposite to blobby
constructs is that the smooth connection is limited to an adjustable distance
from the surface, so the shape itself does not change, and this makes it easier
to design things more exactly.
There's a also second parameter which I call "roundedness", so you can change
the smoothness of the connection. It should be set in a range from greater than
zero up to one, where "1" means a circular transition in normal cases. ("normal
cases" means that the function value increases linearly along the surface's
normal vector)
And as you can see in the attached image, there are also macros allowing to
create something like a "facet" between the objects.

But enough talk, here's the code:

// smooth union
// fn_smooth_union (FUNCTION, FUNCTION, FLOAT, FLOAT)
// param#3: distance
// param#4: roundedness
#macro fn_smooth_union (fn_1, fn_2, fn_d, fn_r)
    #local c_1 = fn_d/2;
    #local c_2 = 2/fn_r;
    #local c_3 = fn_r/2;
    function {
        select (
            max (fn_1 (x, y, z), fn_2 (x, y, z)) - fn_d,
            -pow (pow (fn_d - fn_1 (x, y, z), c_2) +
            pow (fn_d - fn_2 (x, y, z), c_2), c_3) + fn_d,
            min (fn_1 (x, y, z), fn_2 (x, y, z))
        )
    }
#end

// smooth intersection
// fn_smooth_intersection (FUNCTION, FUNCTION, FLOAT, FLOAT)
// param#3: distance
// param#4: roundedness
#macro fn_smooth_intersection (fn_1, fn_2, fn_d, fn_r)
    #local c_1 = fn_d/2;
    #local c_2 = 2/fn_r;
    #local c_3 = fn_r/2;
    function {
        select (
            max (-fn_1 (x, y, z), -fn_2 (x, y, z)) - fn_d,
            pow (pow (fn_d + fn_1 (x, y, z), c_2) +
            pow (fn_d + fn_2 (x, y, z), c_2), c_3) - fn_d,
            max (fn_1 (x, y, z), fn_2 (x, y, z))
        )
    }
#end

// smooth difference
// fn_smooth_difference (FUNCTION, FUNCTION, FLOAT, FLOAT)
// param#3: distance
// param#4: roundedness
#macro fn_smooth_difference (fn_1, fn_2, fn_d, fn_r)
    #local c_1 = fn_d/2;
    #local c_2 = 2/fn_r;
    #local c_3 = fn_r/2;
    function {
        select (
            max (-fn_1 (x, y, z), fn_2 (x, y, z)) - fn_d,
            pow (pow (fn_d + fn_1 (x, y, z), c_2) +
            pow (fn_d - fn_2 (x, y, z), c_2), c_3) - fn_d,
            max (fn_1 (x, y, z), -fn_2 (x, y, z))
        )
    }
#end

// smooth exclusion loose
// fn_smooth_exclusion (FUNCTION, FUNCTION, FLOAT, FLOAT)
// param#3: distance
// param#4: roundedness
#macro fn_smooth_exclusion_loose (fn_1, fn_2, fn_d, fn_r)
    #local c_1 = fn_d/2;
    #local c_2 = 2/fn_r;
    #local c_3 = fn_r/2;
    function {
        min (
            select (
                max (-fn_1 (x, y, z), fn_2 (x, y, z)) - fn_d,
                pow (pow (fn_d + fn_1 (x, y, z), c_2) +
                pow (fn_d - fn_2 (x, y, z), c_2), c_3) - fn_d,
                max (fn_1 (x, y, z), -fn_2 (x, y, z))
            ),
            select (
                max (-fn_2 (x, y, z), fn_1 (x, y, z)) - fn_d,
                pow (pow (fn_d + fn_2 (x, y, z), c_2) +
                pow (fn_d - fn_1 (x, y, z), c_2), c_3) - fn_d,
                max (fn_2 (x, y, z), -fn_1 (x, y, z))
            )
        )
    }
#end

// smooth exclusion connected
// fn_smooth_exclusion (FUNCTION, FUNCTION, FLOAT, FLOAT)
// param#3: distance
// param#4: roundedness
#macro fn_smooth_exclusion_connected (fn_1, fn_2, fn_d, fn_r)
    #local c_1 = fn_d/2;
    #local c_2 = 2/fn_r;
    #local c_3 = fn_r/2;
    function {
        -min (
            -select (
                max (fn_1 (x, y, z), fn_2 (x, y, z)) - fn_d,
                -pow (pow (fn_d - fn_1 (x, y, z), c_2) +
                pow (fn_d - fn_2 (x, y, z), c_2), c_3) + fn_d,
                min (fn_1 (x, y, z), fn_2 (x, y, z))
            ),
            select (
                max (-fn_1 (x, y, z), -fn_2 (x, y, z)) - fn_d,
                pow (pow (fn_d + fn_1 (x, y, z), c_2) +
                pow (fn_d + fn_2 (x, y, z), c_2), c_3) - fn_d,
                max (fn_1 (x, y, z), fn_2 (x, y, z))
            )
        )
    }
#end

// fillet union
// fn_fillet_union (FUNCTION, FUNCTION, FLOAT)
// param#3: distance
#macro fn_fillet_union (fn_1, fn_2, fn_d)
    #local c_1 = fn_d/2;
    function {
        select (
            max (fn_1 (x, y, z), fn_2 (x, y, z)) - fn_d,
            fn_1 (x, y, z) + fn_2 (x, y, z) - fn_d,
            min (fn_1 (x, y, z), fn_2 (x, y, z))
        )
    }
#end

// fillet intersection
// fn_fillet_intersection (FUNCTION, FUNCTION, FLOAT)
// param#3: distance
#macro fn_fillet_intersection (fn_1, fn_2, fn_d)
    #local c_1 = fn_d/2;
    function {
        select (
            max (-fn_1 (x, y, z), -fn_2 (x, y, z)) - fn_d,
            fn_1 (x, y, z) + fn_2 (x, y, z) + fn_d,
            max (fn_1 (x, y, z), fn_2 (x, y, z))
        )
    }
#end

// fillet difference
// fn_fillet_difference (FUNCTION, FUNCTION, FLOAT)
// param#3: distance
#macro fn_fillet_difference (fn_1, fn_2, fn_d)
    #local c_1 = fn_d/2;
    function {
        select (
            max (-fn_1 (x, y, z), fn_2 (x, y, z)) - fn_d,
            fn_1 (x, y, z) - fn_2 (x, y, z) + fn_d,
            max (fn_1 (x, y, z), -fn_2 (x, y, z))
        )
    }
#end

// fillet exclusion loose
// fn_fillet_exclusion_loose (FUNCTION, FUNCTION, FLOAT)
// param#3: distance
#macro fn_fillet_exclusion_loose (fn_1, fn_2, fn_d)
    #local c_1 = fn_d/2;
    function {
        min (
            select (
                max (-fn_1 (x, y, z), fn_2 (x, y, z)) - fn_d,
                fn_1 (x, y, z) - fn_2 (x, y, z) + fn_d,
                max (fn_1 (x, y, z), -fn_2 (x, y, z))
            ),
            select (
                max (-fn_2 (x, y, z), fn_1 (x, y, z)) - fn_d,
                fn_2 (x, y, z) - fn_1 (x, y, z) + fn_d,
                max (fn_2 (x, y, z), -fn_1 (x, y, z))
            )
        )
    }
#end

// fillet exclusion connected
// fn_fillet_exclusion_connected (FUNCTION, FUNCTION, FLOAT)
// param#3: distance
#macro fn_fillet_exclusion_connected (fn_1, fn_2, fn_d)
    #local c_1 = fn_d/2;
    function {
        -min (
            -select (
                max (fn_1 (x, y, z), fn_2 (x, y, z)) - fn_d,
                fn_1 (x, y, z) + fn_2 (x, y, z) - fn_d,
                min (fn_1 (x, y, z), fn_2 (x, y, z))
            ),
            select (
                max (-fn_1 (x, y, z), -fn_2 (x, y, z)) - fn_d,
                fn_1 (x, y, z) + fn_2 (x, y, z) + fn_d,
                max (fn_1 (x, y, z), fn_2 (x, y, z))
            )
        )
    }
#end

Regards,
Florian


Post a reply to this message


Attachments:
Download 'smooth_csg.jpg' (294 KB)

Preview of image 'smooth_csg.jpg'
smooth_csg.jpg


 

From: Thomas de Groot
Subject: Re: smooth csg
Date: 4 Mar 2012 02:56:31
Message: <4f53202f$1@news.povray.org>
I love you guys!  :-)

Thomas


Post a reply to this message

From: Tek
Subject: Re: smooth csg
Date: 5 Mar 2012 04:40:01
Message: <web.4f5489ccbc71efa9a4faf9d60@news.povray.org>
That's a very different approach to what I'm doing. Though the results look
nice.


"Florian Siegmund" <flo### [at] gmxat> wrote:
> clipka <ano### [at] anonymousorg> wrote:
> >
> > You do care to share those macros, don't you? <drool>
>
> Hi folks!
>
> I also wrote some function macros for building smooth csg objects with
> isosurfaces some time ago. The advatage of these macros in opposite to blobby
> constructs is that the smooth connection is limited to an adjustable distance
> from the surface, so the shape itself does not change, and this makes it easier
> to design things more exactly.
> There's a also second parameter which I call "roundedness", so you can change
> the smoothness of the connection. It should be set in a range from greater than
> zero up to one, where "1" means a circular transition in normal cases. ("normal
> cases" means that the function value increases linearly along the surface's
> normal vector)
> And as you can see in the attached image, there are also macros allowing to
> create something like a "facet" between the objects.
....
> Regards,
> Florian


Post a reply to this message

From: Florian Siegmund
Subject: Re: smooth csg
Date: 5 Mar 2012 11:30:00
Message: <web.4f54e9c4bc71efa9553e4e470@news.povray.org>
"Tek" <tek### [at] evilsuperbraincom> wrote:
> That's a very different approach to what I'm doing. Though the results look
> nice.

For the more artistic matter, here are two different function blob macros of
mine. If you want to create a surface that is as smooth as possible, the
exponential blob is the right choice, but the final shape is hardly predictable,
so it's a bit of trial-and-error. The arctangent blob is less smooth, but it's
easier to handle, because the shapes do not change as much as in the first case.

The code:

// exponential blob
// fn_exp_blob (FUNCTION, FLOAT)
// fn_exp_blob_element (FUNCTION, FLOAT)
// [fn_exp_blob_element (FUNCTION, FLOAT)]
// ...
// fn_exp_blob_end ()
// param#2: threshold
#macro fn_exp_blob (fn_1, fn_th)
    function {1 + fn_th - pow (fn_th, fn_1 (x, y, z))
#end
#macro fn_exp_blob_element (fn_1, fn_th)
    - pow (fn_th, fn_1 (x, y, z))
#end
#macro fn_exp_blob_end ()
    }
#end

// arctangent blob
// fn_atan_blob (FUNCTION, FLOAT)
// fn_atan_blob_element (FUNCTION, FLOAT)
// [fn_atan_blob_element (FUNCTION, FLOAT)]
// ...
// fn_atan_blob_end ()
// param#2: threshold
#macro fn_atan_blob (fn_1, fn_th)
    function {(atan (fn_1 (x, y, z)/fn_th)
#end
#macro fn_atan_blob_element (fn_1, fn_th)
    + atan (fn_1 (x, y, z)/fn_th) - pi/2
#end
#macro fn_atan_blob_end ()
    )/pi*2}
#end


You can use it like this:

#declare my_blob_function =
    fn_exp_blob (function_1, threshold_1)
    fn_exp_blob_element (function_2, threshold_2)
    [fn_exp_blob_element (function_3, threshold_3)]
    ...
    fn_exp_blob_end ()


Florian


Post a reply to this message


Attachments:
Download 'isosurface_blob.jpg' (120 KB)

Preview of image 'isosurface_blob.jpg'
isosurface_blob.jpg


 

Goto Latest 10 Messages Next 2 Messages >>>

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