POV-Ray : Newsgroups : povray.general : rounded_objects: a new feature? Server Time
17 May 2024 17:09:27 EDT (-0400)
  rounded_objects: a new feature? (Message 5 to 14 of 24)  
<<< Previous 4 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: John Greenwood
Subject: Re: rounded_objects: a new feature?
Date: 15 Sep 2016 13:10:00
Message: <web.57dad3c8696ad3a7cafab50@news.povray.org>
scott <sco### [at] scottcom> wrote:

> It actually sounds similar to distance field rendering which is used a
> lot in real-time raytracing. Once you have the distance fields then it's
> easy to do a "smooth union" between shapes:
>
> http://www.iquilezles.org/www/articles/smin/smin.htm

Alain wrote:
> You may do a blobbing of the intersection of four planes to get a
> rounded tetrahedron, of six planes for a rounded box,...
> Possible, done before and relatively slow.

I think this means that what I am suggesting is feasible, and indeed already
do-able to a limited extent.

However both the blob definition and isosurfaces are for me non-intuitve.

Take the tetrahedron for example, I will probably know where I want the four
vertices to be, so defining each of the four rounded_object plane elements with
three vectors is simple. Writing it as a set of equasions needs a bit of
pondering, which is what computers are for.

I can see how blob definition has been written in its simplest form by
programmers, but for the user it would be much more convenient to input the
radius of the sphere that would be seen in isolation and the distance the field
extends beyond this. I know these relate to the actual input parameters by very
simple arithmetic, which is also is what computers are for.

Of course calculating field strengths is going to slow things down, but would it
be possible to be able to have a fast mode where this left out and the object
rendered with sharp corners?

I think implementing rounded-object with just planes, cylinders and spheres
would not be that difficult and would give:
- an immediate improvement in usability.
- Individual radii for planes would enable a significant new repertoire of
rounded shapes.
- Rounded objects as elements would extend this
- sphere sweep elements would be amazing.

scott <sco### [at] scottcom> wrote:

> Note that there are two distinct types of "round" being discussed, it's
> important not to confuse them. The first is the "CAD" type of perfect
> round that is formed by conceptually rolling a sphere (of radius equal
> to the round you want) along the edge. The second is this type of
> "artistic" round that smoothly blends the two shapes, but is not
> necessarily possible to accurately specify the round radius (or it might
> not even be constant throughout the round).

My point exactly when I wrote:

> >(The calculation might be faster with cubic; the corners would not be exactly
> > circular, but would anyone notice or care?)

Maybe we could go further and, with an extra optional parameter, change the
profile of the rounding from a rounded bevel to a "V" shape?


Post a reply to this message

From: Alain
Subject: Re: rounded_objects: a new feature?
Date: 15 Sep 2016 13:57:33
Message: <57dae10d$1@news.povray.org>



>
> I can see how blob definition has been written in its simplest form by
> programmers, but for the user it would be much more convenient to input the
> radius of the sphere that would be seen in isolation and the distance the field
> extends beyond this. I know these relate to the actual input parameters by very
> simple arithmetic, which is also is what computers are for.

This will only work for non-interacting blob elements. Whenever two or 
more elements interact, the location of the surface will get pushed away 
from that location. It can be pushed inward or outward depending on the 
strength of each component. Remember that a blob component can have a 
negative strength.

>
> Of course calculating field strengths is going to slow things down, but would it
> be possible to be able to have a fast mode where this left out and the object
> rendered with sharp corners?

The actual rounded "primitives" are really unions of several shapes.
The rounded box use no less that 7 boxes, 12 cylinders and 8 spheres.
The rounded cylinder and cone use 2 cylinders and 2 torus, or a cylinder 
and 2 spheres.
They have the normal, union, mode and the merge mode for use with 
transparent textures where you don't want the inner surfaces to mess up 
things.

>
> I think implementing rounded-object with just planes, cylinders and spheres
> would not be that difficult and would give:
> - an immediate improvement in usability.
I don't think so.

> - Individual radii for planes would enable a significant new repertoire of
> rounded shapes.
A plane is a plane, a simple surface extending to infinity, it have no 
roundness. In POV-Ray, a plane have the geometric definition of a plane: 
An infinite, infinitely thin, surface dividing space in two: above and 
under.

> - Rounded objects as elements would extend this
> - sphere sweep elements would be amazing.

The sphere_sweep primitive exist and is far from trivial, even for 
linear sweeps. Adding blobbing or rounded edges would be absolutely 
nightmarish.
How would you round the edge of an irregular twisting tube and a plane, 
given that the tube can have a variable curvature,  radius and elevation 
over the plane, can travel under the plane or above.
Except in the most trivial cases, you can't make an isosurface 
equivalent of the sphere_sweep.

>
> scott <sco### [at] scottcom> wrote:
>
>> Note that there are two distinct types of "round" being discussed, it's
>> important not to confuse them. The first is the "CAD" type of perfect
>> round that is formed by conceptually rolling a sphere (of radius equal
>> to the round you want) along the edge. The second is this type of
>> "artistic" round that smoothly blends the two shapes, but is not
>> necessarily possible to accurately specify the round radius (or it might
>> not even be constant throughout the round).
>
> My point exactly when I wrote:
>
>>> (The calculation might be faster with cubic; the corners would not be exactly
>>> circular, but would anyone notice or care?)
>
> Maybe we could go further and, with an extra optional parameter, change the
> profile of the rounding from a rounded bevel to a "V" shape?
>
>
>
>


Post a reply to this message

From: scott
Subject: Re: rounded_objects: a new feature?
Date: 16 Sep 2016 02:47:43
Message: <57db958f$1@news.povray.org>
> scott <sco### [at] scottcom> wrote:
>
>> Note that there are two distinct types of "round" being discussed, it's
>> important not to confuse them. The first is the "CAD" type of perfect
>> round that is formed by conceptually rolling a sphere (of radius equal
>> to the round you want) along the edge. The second is this type of
>> "artistic" round that smoothly blends the two shapes, but is not
>> necessarily possible to accurately specify the round radius (or it might
>> not even be constant throughout the round).
>
> My point exactly when I wrote:
>
>>> (The calculation might be faster with cubic; the corners would not be exactly
>>> circular, but would anyone notice or care?)
>
> Maybe we could go further and, with an extra optional parameter, change the
> profile of the rounding from a rounded bevel to a "V" shape?

I don't think the method you are suggesting is capable of generating 
correct rounds (with constant radius curvature and tangent to both 
faces) nor creating a constant "V" profile (a bevel). But willing to be 
proved wrong, give it a go with some simple shapes and isosurfaces/blobs 
and see what you get. If you're on to something then some working 
example code will go *far* further than just a text description.


Post a reply to this message

From: John Greenwood
Subject: Re: rounded_objects: a new feature?
Date: 16 Sep 2016 05:25:00
Message: <web.57dbb989696ad3a7cafab50@news.povray.org>
scott <sco### [at] scottcom> wrote:
> > scott <sco### [at] scottcom> wrote:
> >
> >> Note that there are two distinct types of "round" being discussed, it's
> >> important not to confuse them. The first is the "CAD" type of perfect
> >> round that is formed by conceptually rolling a sphere (of radius equal
> >> to the round you want) along the edge. The second is this type of
> >> "artistic" round that smoothly blends the two shapes, but is not
> >> necessarily possible to accurately specify the round radius (or it might
> >> not even be constant throughout the round).
> >
> > My point exactly when I wrote:
> >
> >>> (The calculation might be faster with cubic; the corners would not be exactly
> >>> circular, but would anyone notice or care?)
> >
> > Maybe we could go further and, with an extra optional parameter, change the
> > profile of the rounding from a rounded bevel to a "V" shape?
>
> I don't think the method you are suggesting is capable of generating
> correct rounds (with constant radius curvature and tangent to both
> faces) nor creating a constant "V" profile (a bevel). But willing to be
> proved wrong, give it a go with some simple shapes and isosurfaces/blobs
> and see what you get. If you're on to something then some working
> example code will go *far* further than just a text description.

Totally agree, I am working on it.

The aim is for a tangent at both ends with a smooth curve in between. A constant
radius is only needed in CAD to specify the shape of a real thing. Here, if it
looks good. it is good.


Post a reply to this message

From: Bald Eagle
Subject: Re: rounded_objects: a new feature?
Date: 16 Sep 2016 12:25:00
Message: <web.57dc1bb7696ad3b488d9aa0@news.povray.org>
Alain <kua### [at] videotronca> wrote:

> Except in the most trivial cases, you can't make an isosurface
> equivalent of the sphere_sweep.

What about:

http://www.econym.demon.co.uk/isotut/splines.htm

?


Post a reply to this message

From: John Greenwood
Subject: Re: rounded_objects: a new feature?
Date: 17 Sep 2016 07:25:00
Message: <web.57dd278e696ad3a7cafab50@news.povray.org>
> > If you're on to something then some working
> > example code will go *far* further than just a text description.
>
> Totally agree, I am working on it.

And here it is:

// This work is licensed under the Creative Commons Attribution 3.0 Unported
License.
// To view a copy of this license, visit
http://creativecommons.org/licenses/by/3.0/
// or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain
View,
// California, 94041, USA.

// Demonstration of plane elements for rounded objects

// Vers: 1.00
// Date: 17 Sept 2016
// Auth: John Greenwood

#version 3.7 ;

#include "colors.inc"

camera {location <10,10,10> angle 30 look_at <0,0,0> }

  background { color rgb<0.2, 0.4, 0.8>  }
  light_source {<10,20,5> color White}
  global_settings {assumed_gamma 1.0 }

  #declare Corner_Profile = -.5;   // -.5 gives rounded bevel, 0 almost round,
+.5 Not noticebly sharper
  #declare Corner_round = 1;

  #declare R_plane = function( X,r,s){

select((X>r)-(X<-r),2*(r<0)-1,s*pow(X/r,5)-(2*s+.5)*pow(X/r,3)+(1.5+s)*X/r,1-2*(r<0))
                                     }
  isosurface {
     function {
               R_plane(x+1.5,-Corner_round,Corner_Profile)
              +R_plane(x-1.5,+Corner_round,Corner_Profile)
              +R_plane(y-1.5, Corner_round,Corner_Profile)
              +R_plane(y+1.5,-Corner_round,Corner_Profile)
              +R_plane(z-1.5,+Corner_round,Corner_Profile)
              +R_plane(z+1.5,-Corner_round,Corner_Profile)
              }
     threshold -5


      max_gradient 6
    contained_by { box { -2, 2 } }
 texture {
  pigment {color rgb < 1, 0.9, 0.65>}
  }
  }

/**
// Example 1. Notes: changing the threshold does have the effect of
shrinking/swelling the object. Corner_round = 1.5 Corner_Profile = -.5 gives a
rounded octrahedron
     function {
               R_plane(x+1.5,-Corner_round,Corner_Profile)
              +R_plane(x-1.5,+Corner_round,Corner_Profile)
              +R_plane(y-1.5, Corner_round,Corner_Profile)
              +R_plane(y+1.5,-Corner_round,Corner_Profile)
              +R_plane(z-1.5,+Corner_round,Corner_Profile)
              +R_plane(z+1.5,-Corner_round,Corner_Profile)
              }
     threshold -5
// Example 2. Demonstrates not all the same corner profile
     function {
               R_plane(x-1.5,+.5,0)
              +R_plane(x+1.5,-2,0)
              +R_plane(y-1.5, 1,-.5)
              +R_plane(y+1.5,-1,-.5)
              +R_plane(z-1.5,+1,-.5)
              +R_plane(z+1.5,-1,-.5)
              }
     threshold -5
//Example 3. Five planes, not all othogonal
     function {
               R_plane(x+1.5,-Corner_round,Corner_Profile)
              +R_plane(x-1.5,+Corner_round,Corner_Profile)
              +R_plane(y+1.5,-Corner_round,Corner_Profile)
              +R_plane(y+z-1,+Corner_round,Corner_Profile)
              +R_plane(z+1.5,-Corner_round,Corner_Profile)
              }
     threshold -4
//Example 4. Corner definitions can be variable: Round
     function {
               R_plane(x+1.5,-.5,Corner_Profile)
              +R_plane(x-1.5,+1.5,Corner_Profile)
              +R_plane(y-1.5, Corner_round+.5*x,Corner_Profile)
              +R_plane(y+1.5,-Corner_round-.5*x,Corner_Profile)
              +R_plane(z-1.5,+Corner_round+.5*x,Corner_Profile)
              +R_plane(z+1.5,-Corner_round-.5*x,Corner_Profile)
              }
     threshold -5

//Example 5. Corner definitions can be variable: profile
     function {
               R_plane(x+1.5,-.4,0)
              +R_plane(x-1.5,+.4,0)
              +R_plane(y-1.5, Corner_round,Corner_Profile*x)
              +R_plane(y+1.5,-Corner_round,Corner_Profile*x)
              +R_plane(z-1.5,+Corner_round,Corner_Profile*x)
              +R_plane(z+1.5,-Corner_round,Corner_Profile*x)
              }
     threshold -5

*/


Post a reply to this message

From: John Greenwood
Subject: Re: rounded_objects: a new feature?
Date: 18 Sep 2016 07:00:01
Message: <web.57de7375696ad3a7cafab50@news.povray.org>
"John Greenwood" <nomail@nomail> wrote:
> And here it is:

> // Demonstration of plane elements for rounded objects

And now spheres:

// This work is licensed under the Creative Commons Attribution 3.0 Unported
License.
// To view a copy of this license, visit
http://creativecommons.org/licenses/by/3.0/
// or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain
View,
// California, 94041, USA.

// Demonstration of Sphere elements for rounded objects

// Vers: 1.00
// Date: 18 Sept 2016
// Auth: John Greenwood

#version 3.7 ;

#include "colors.inc"

camera {location <0,0,22> angle 30 look_at <0,0,0> }

  background { color rgb<0.2, 0.4, 0.8>  }
  light_source {<5,20,10> color White}
  global_settings {assumed_gamma 1.0 }


  #declare R_function = function( F,q,s){

select((F>q)-(F<-q),2*(q<0)-1,s*pow(F/q,5)-(2*s+.5)*pow(F/q,3)+(1.5+s)*F/q,1-2*(q<0))
                                        }


  isosurface {
     function    {
               R_function(-sqrt(pow(x-1,2)+pow(y,2)+pow(z,2))+1,-1,0)
               +R_function(-sqrt(pow(x+1,2)+pow(y,2)+pow(z,2))+1 ,-.5,0)
                 }
     threshold  1
      max_gradient 4
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}}
            translate < 3,3,0>  }

  isosurface {
     function    {
               R_function(-sqrt(pow(x-1,2)+pow(y,2)+pow(z,2))+1,-.5,.3)
               +R_function(-sqrt(pow(x+1,2)+pow(y,2)+pow(z,2))+1 ,-.5,-.4)
                 }
     threshold  1
      max_gradient 3
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}  }
      translate <-3,3,0>        }

  isosurface {
     function     {

R_function(-sqrt(pow(x-1,2)+pow(y,2)+pow(z,2))+1,min(-.3,-.5-.4*-y),0)

+R_function(-sqrt(pow(x+1,2)+pow(y,2)+pow(z,2))+1,min(-.3,-.5-.4*+y),0)
                 }
     threshold  1
      max_gradient 5
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}  }
     translate <3,-0,0>         }

  isosurface {
     function    {
                R_function(-sqrt(pow(x-1,2)+pow(y,2)+pow(z,2))+1,-.5,y)
               +R_function(-sqrt(pow(x+1,2)+pow(y,2)+pow(z,2))+1,-.5,-y)
                 }
     threshold  1
      max_gradient 4
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}  }
      translate <-3,-0,0>        }

  isosurface {
     function     {
                R_function(-sqrt(pow(x-1,2)+pow(y,2)+pow(z,2))+.5,-2,-.5)
               +R_function(-sqrt(pow(x+1,2)+pow(y,2)+pow(z,2))+1,-1,0)
                 }
     threshold  1
      max_gradient 3
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}  }
     translate <3,-3,0>         }

  isosurface {
     function    {
                R_function(-sqrt(pow(x-1,2)+pow(y,2)+pow(z,2))+.5,-1,0)
               +R_function(-sqrt(pow(x+1,2)+pow(y,2)+pow(z,2))+1,-1.5,0)
                 }
     threshold  1
      max_gradient 4
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}  }
      translate <-3,-3,0>        }


Post a reply to this message

From: scott
Subject: Re: rounded_objects: a new feature?
Date: 19 Sep 2016 03:20:15
Message: <57df91af$1@news.povray.org>
>>> If you're on to something then some working
>>> example code will go *far* further than just a text description.
>>
>> Totally agree, I am working on it.
>
> And here it is:

A good start!

How would you go about doing the union (or difference) of two rounded 
cubes? I tried to modify the code to do this but couldn't get it to 
work. If that works nicely then I think you're on to something...

BTW you could always use a macro for each element, that depending on 
some global switch, either used the standard POV non-rounded primitive 
(for speed of setting up the scene) or the isosurface variant (for final 
render).


Post a reply to this message

From: John Greenwood
Subject: Re: rounded_objects: a new feature?
Date: 19 Sep 2016 05:05:01
Message: <web.57dfaa2e696ad3a7cafab50@news.povray.org>
scott <sco### [at] scottcom> wrote:
> >>> If you're on to something then some working
> >>> example code will go *far* further than just a text description.
> >>
> >> Totally agree, I am working on it.
> >
> > And here it is:
>
> A good start!
>
> How would you go about doing the union (or difference) of two rounded
> cubes? I tried to modify the code to do this but couldn't get it to
> work. If that works nicely then I think you're on to something...
>
> BTW you could always use a macro for each element, that depending on
> some global switch, either used the standard POV non-rounded primitive
> (for speed of setting up the scene) or the isosurface variant (for final
> render).

I think I have a plan!

Meanwhile here are some cylinders:

// This work is licensed under the Creative Commons Attribution 3.0 Unported
License.
// To view a copy of this license, visit
http://creativecommons.org/licenses/by/3.0/
// or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain
View,
// California, 94041, USA.

// Demonstration of Cylinder elements for rounded objects

// Vers: 1.00
// Date: 18 Sept 2016
// Auth: John Greenwood

#version 3.7 ;

#include "colors.inc"

camera {location <0,0,17> angle 25 look_at <0,-.30,0> }

  background { color rgb<0.2, 0.4, 0.8>  }
  light_source {<5,10,20> color White}
  global_settings {assumed_gamma 1.0 }


  #declare R_function = function( F,q,p,n){

select((F>q)-(F<-q),2*(q<0)-1,p*pow(F/q,5)-(2*p+.5)*pow(F/q,3)+(1.5+p)*F/q,1-2*(q<0))+n
                                        }


  isosurface {
     function    {
               R_function(-sqrt(pow(y-1,2)+pow(z,2))+.4-.1*x,-.5,0,-1)
              +R_function(-sqrt(pow(y+1.5,2)+pow(z,2))+1.9,-.3,0,-1)
              +R_function(x+1.5,-.3,0,1)
              +R_function(x-1.5,+.3,0,1)
              +R_function(y,-.3,0,1)
                }
     threshold -1
      max_gradient 6
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}}
            translate < 0,.7,0>  }


  isosurface {
     function    {
               R_function(-sqrt(pow(y-1,  2)+pow(z,2))+ .5,-.3,.2+.5*x,-1)
              +R_function(-sqrt(pow(y+1.5,2)+pow(z,2))+1.9,-.3,.2+.5*x,-1)
              +R_function(x+1.5,-.3,0,1)
              +R_function(x-1.5,+.3,0,1)
              +R_function(y    ,-.5,0,1)
                }
     threshold -1
      max_gradient 6
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}}
            translate < 0,-1,0>  }

  isosurface {
     function    {
               R_function(-sqrt(pow(y-1  ,2)+pow(z,2))+ .4,-.5+.2*x,0,-1)
              +R_function(-sqrt(pow(y+1.5,2)+pow(z,2))+1.9,-.5+.2*x,0,-1)
              +R_function(x+1.5,-.3,0,1)
              +R_function(x-1.5,+.3,0,1)
              +R_function(y+1    ,-.5,0,1)
                }
     threshold -1
      max_gradient 6
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}}
            translate < 0,-2.7,0>  }


Post a reply to this message

From: John Greenwood
Subject: Re: rounded_objects: a new feature?
Date: 19 Sep 2016 07:15:00
Message: <web.57dfc85c696ad3a7cafab50@news.povray.org>
"John Greenwood" <nomail@nomail> wrote:
> scott <sco### [at] scottcom> wrote:
> >
> > How would you go about doing the union (or difference) of two rounded
> > cubes? I tried to modify the code to do this but couldn't get it to
> > work. If that works nicely then I think you're on to something...
> >
> > BTW you could always use a macro for each element, that depending on
> > some global switch, either used the standard POV non-rounded primitive
> > (for speed of setting up the scene) or the isosurface variant (for final
> > render).
>
> I think I have a plan!
>
> Meanwhile here are some cylinders:

And, more exciting, bendy cylinders!

// This work is licensed under the Creative Commons Attribution 3.0 Unported
License.
// To view a copy of this license, visit
http://creativecommons.org/licenses/by/3.0/
// or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain
View,
// California, 94041, USA.

// Demonstration of Bendy Cylinder elements for rounded objects

// Vers: 1.00
// Date: 19 Sept 2016
// Auth: John Greenwood

#version 3.7 ;

#include "colors.inc"

camera {location <5,10,17> angle 10 look_at <0,0,0> }

  background { color rgb<0.2, 0.4, 0.8>  }
  light_source {<5,10,20> color White}
  global_settings {assumed_gamma 1.0 }


  #declare R_function = function( F,q,p,n){

select((F>q)-(F<-q),2*(q<0)-1,p*pow(F/q,5)-(2*p+.5)*pow(F/q,3)+(1.5+p)*F/q,1-2*(q<0))+n
                                        }


  isosurface {
     function    {
               R_function(-sqrt(pow(y-.6+.1*x-.1*pow(x,3),  2)+pow(z,2))+
..2,-.1,0,-1)
              +R_function(-sqrt(pow(y+1.5,2)+pow(z,2))+1.9,-.1,0,-1)
              +R_function(x+1.5,-.1,0,1)
              +R_function(x-1.5,+.1,0,1)
              +R_function(y    ,-.5,0,1)
                }
     threshold -1
      max_gradient 20
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}}
            translate < 0,-.5,0>  }

// note that the cross section is a vertical circle, which means that it will be
elliptical on a plane perpendicular to the cuved axis.
// I think this can be compensated for by taking the slope of the curve into
account.

// I have not worked out the details but I think this is a route to sphere
sweeps.


Post a reply to this message

<<< Previous 4 Messages Goto Latest 10 Messages Next 10 Messages >>>

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