POV-Ray : Newsgroups : povray.general : Isofunctions and meshes Server Time
19 Apr 2024 01:44:22 EDT (-0400)
  Isofunctions and meshes (Message 11 to 20 of 24)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 4 Messages >>>
From: Tor Olav Kristensen
Subject: Re: Isofunctions and meshes
Date: 2 Dec 2016 12:30:00
Message: <web.5841af1fb9cec73d6ebf07f0@news.povray.org>
"John Greenwood" <joh### [at] john-greenwoodcouk> wrote:
> "Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> > "John Greenwood" <joh### [at] john-greenwoodcouk> wrote:
>
> >> can my function, which is a single closed surface, be turned into mesh?
> >
> > Perhaps you can find something useful in this thread:
> >
> > Subject: Isosurface Approximation macros rewrite
> > From: Tor Olav Kristensen
> > Date: 2008 February 22nd
> > Message: <47be20ab@news.povray.org>
> > Newsgroup: povray.binaries.scene-files
> >
> >
http://news.povray.org/povray.binaries.scene-files/thread/%3C47cc76fd@news.povray.org%3E/
> >
> > --
> > Tor Olav
> > http://subcube.com
>
> I have had a look and am floundering.
>
> An example would be worth ten thousand words.

See the code below.


> Could some kind person point me at an actual example of converting a simple
> function, such as:
>     function(x,y,z){sqrt(pow(x,2)+pow(y,2)+pow(z,2))-L)/r }
> into a mesh object?

That function seemsto be missing a start parenthesis somewhere.
The code below uses a similar function.

Noe that this code also creates a file named triangles.inc that contains all the
triangles.

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8

#include "functions.inc"

// Other functions to experiment with
//#declare Fn = function { f_torus(x, y, z, 1, 0.4) }
//#declare Fn = function { y - sin(2*x*z)*cos(x*z) }
//#declare Fn = function { cos(2*pi*x) + cos(2*pi*y) + cos(2*pi*z) }

// A sphere with radius 1.8
// x^2 + y^2 + z^2 = 1.8^2
// (x^2 + y^2 + z^2)^(1/2) = 1.8
// (x^2 + y^2 + z^2)^(1/2) - 1.8 = 0.0

// The elaborate way
//#declare Fn = function(x, y, z) { sqrt(pow(x,2) + pow(y,2) + pow(z,2)) - 1.8 }

// A simpler way
#declare Fn = function { f_sphere(x, y, z, 1.8) }

#declare isoThreshold = 0.0;

// Set to yes to produce the approximation
// or to no for the actual isosurface
#declare approximateIso = yes;

// Set to yes to produce a smooth_triangle approximation
// or to no ro produce a flat triangle approximation
#declare isoSmooth = no;

// Controls the size of the cube that is beeing sampled
#declare R = 2.0;

#declare isoMin = -<1, 1, 1>*R;
#declare isoMax = +<1, 1, 1>*R;

// The resolution of the sampling in the x, y and z directions
#declare Resolution = 6;

#if (approximateIso)
  #declare Depth = 1; // Set to 0 for no recursion
  #declare isoSegs = <1, 1, 1>*Resolution;
  #declare isoFileOption = 1;
  #declare isoFile = "triangles.inc";
  #declare isoName = "Surface";
  #include "isosurface_kl_jf_tok.inc"
  object {
    Surface
    pigment { color rgb <1, 1, 1>*0.9 }
    finish {
      phong 0.5
      phong_size 10
    }
  }
#else
  isosurface {
    function { Fn(x, y, z) }
    max_gradient 8.0
    contained_by { box { isoMin, isoMax } }
    open
    pigment { color rgb <1, 1, 1>*0.9 }
    finish {
      phong 0.5
      phong_size 10
    }
  }
#end // if

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8

sky_sphere {
  pigment {
    function { abs(y) }
    color_map {
      [ 0.0 color rgb <0.0, 0.0, 0.6> ]
      [ 1.0 color rgb <1.0, 1.0, 1.0> ]
    }
  }
}

camera {
  location <1, 2, -4>*2*R
  look_at <0, 0, 0>
  angle 32
}

light_source {
  <1, 2, -1>*100
  color rgb <1, 1, 1>
  shadowless
}

light_source {
  <-1, -2, -1>*100
  color rgb <1, 1, 1>*0.5
  shadowless
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8


--
Tor Olav
http://subcube.com


Post a reply to this message

From: John Greenwood
Subject: Re: Isofunctions and meshes
Date: 3 Dec 2016 05:00:01
Message: <web.584296c5b9cec73de15d43a80@news.povray.org>
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> "John Greenwood" <joh### [at] john-greenwoodcouk> wrote:
> > "Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> > > "John Greenwood" <joh### [at] john-greenwoodcouk> wrote:

> > I have had a look and am floundering.
> >
> > An example would be worth ten thousand words.
>
> See the code below.
>
>
> > Could some kind person point me at an actual example of converting a simple
> > function, such as:
> >     function(x,y,z){sqrt(pow(x,2)+pow(y,2)+pow(z,2))-L)/r }
> > into a mesh object?
>
> That function seemsto be missing a start parenthesis somewhere.
> The code below uses a similar function.
>
> Noe that this code also creates a file named triangles.inc that contains all the
> triangles.
>
> // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8
>
> #include "functions.inc"
>
> // Other functions to experiment with
> //#declare Fn = function { f_torus(x, y, z, 1, 0.4) }
> //#declare Fn = function { y - sin(2*x*z)*cos(x*z) }
> //#declare Fn = function { cos(2*pi*x) + cos(2*pi*y) + cos(2*pi*z) }
>
> // A sphere with radius 1.8
> // x^2 + y^2 + z^2 = 1.8^2
> // (x^2 + y^2 + z^2)^(1/2) = 1.8
> // (x^2 + y^2 + z^2)^(1/2) - 1.8 = 0.0
>
> // The elaborate way
> //#declare Fn = function(x, y, z) { sqrt(pow(x,2) + pow(y,2) + pow(z,2)) - 1.8 }
>
> // A simpler way
> #declare Fn = function { f_sphere(x, y, z, 1.8) }
>
> #declare isoThreshold = 0.0;
>
> // Set to yes to produce the approximation
> // or to no for the actual isosurface
> #declare approximateIso = yes;
>
> // Set to yes to produce a smooth_triangle approximation
> // or to no ro produce a flat triangle approximation
> #declare isoSmooth = no;
>
> // Controls the size of the cube that is beeing sampled
> #declare R = 2.0;
>
> #declare isoMin = -<1, 1, 1>*R;
> #declare isoMax = +<1, 1, 1>*R;
>
> // The resolution of the sampling in the x, y and z directions
> #declare Resolution = 6;
>
> #if (approximateIso)
>   #declare Depth = 1; // Set to 0 for no recursion
>   #declare isoSegs = <1, 1, 1>*Resolution;
>   #declare isoFileOption = 1;
>   #declare isoFile = "triangles.inc";
>   #declare isoName = "Surface";
>   #include "isosurface_kl_jf_tok.inc"
>   object {
>     Surface
>     pigment { color rgb <1, 1, 1>*0.9 }
>     finish {
>       phong 0.5
>       phong_size 10
>     }
>   }
> #else
>   isosurface {
>     function { Fn(x, y, z) }
>     max_gradient 8.0
>     contained_by { box { isoMin, isoMax } }
>     open
>     pigment { color rgb <1, 1, 1>*0.9 }
>     finish {
>       phong 0.5
>       phong_size 10
>     }
>   }
> #end // if
>
> // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8
>
> sky_sphere {
>   pigment {
>     function { abs(y) }
>     color_map {
>       [ 0.0 color rgb <0.0, 0.0, 0.6> ]
>       [ 1.0 color rgb <1.0, 1.0, 1.0> ]
>     }
>   }
> }
>
> camera {
>   location <1, 2, -4>*2*R
>   look_at <0, 0, 0>
>   angle 32
> }
>
> light_source {
>   <1, 2, -1>*100
>   color rgb <1, 1, 1>
>   shadowless
> }
>
> light_source {
>   <-1, -2, -1>*100
>   color rgb <1, 1, 1>*0.5
>   shadowless
> }
>
> // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 ======= 8
>
>
> --
> Tor Olav
> http://subcube.com

Thanks I will have a go.


Post a reply to this message

From: John Greenwood
Subject: Re: Isofunctions and meshes
Date: 3 Dec 2016 07:30:00
Message: <web.5842b5f4b9cec73de15d43a80@news.povray.org>
"John Greenwood" <joh### [at] john-greenwoodcouk> wrote:
> "Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> > "John Greenwood" <joh### [at] john-greenwoodcouk> wrote:
> > > "Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> > > > "John Greenwood" <joh### [at] john-greenwoodcouk> wrote:
>
> > > I have had a look and am floundering.
> > >
> > > An example would be worth ten thousand words.

> > The code below uses a similar function.
snip
> > --
> > Tor Olav
> > http://subcube.com
>
> Thanks I will have a go.

I have had a go and it works!

This is a great help for composing rounded objects. By reducing the resolution
to 5(and ignoring the artifacts) and putting isoSmooth = no, the render time is
4 seconds, AND I can have muliple views, almost essential for creating 3D
objects.

A single isosurface rendering took 88 seconds

I understand that with a mesh object I can change the colour locally. This will
be much better for introducing lip colours and rosy cheeks in this example.

Thanks
John

(I have posted the result in povray.binaries.images/ but am not clear if and how
to make it appear here)


Post a reply to this message

From: omniverse
Subject: Re: Isofunctions and meshes
Date: 4 Dec 2016 14:15:00
Message: <web.58446a6bb9cec73d9c5d6c810@news.povray.org>
"John Greenwood" <joh### [at] john-greenwoodcouk> wrote:
>
> I understand that with a mesh object I can change the colour locally. This will
> be much better for introducing lip colours and rosy cheeks in this example.
>
> (I have posted the result in povray.binaries.images/ but am not clear if and how
> to make it appear here)

If by a link...?

http://news.povray.org/web.5842b2dd261ae99ae15d43a80%40news.povray.org

That object to mesh stuff is fascinating, unfortunately I'm terrible with
meshes. And not so good with isosurfaces either. LOL

Looks like you got a fair result. When I tried the in-pov converting from Chris
Young I was getting inner CSG surfaces found until changing from unions to
merge. Something I hadn't expected. No idea what could happen with isosurfaces
based on that.

Wish you luck.

Bob


Post a reply to this message

From: John Greenwood
Subject: Re: Isofunctions and meshes
Date: 6 Dec 2016 06:45:00
Message: <web.5846a39db9cec73de15d43a80@news.povray.org>
"omniverse" <omn### [at] charternet> wrote:
> "John Greenwood" <joh### [at] john-greenwoodcouk> wrote:
> That object to mesh stuff is fascinating, unfortunately I'm terrible with
> meshes. And not so good with isosurfaces either. LOL
>
> Looks like you got a fair result. When I tried the in-pov converting from Chris
> Young I was getting inner CSG surfaces found until changing from unions to
> merge. Something I hadn't expected. No idea what could happen with isosurfaces
> based on that.
>
> Wish you luck.
>
> Bob

Thanks

I meshed this shape with different settings for resolution. The values are shown
under each example.

isoSmooth was set to no. The failures seem to happen regardless but this gives
an indication that in the first example, with resolution = 5, the failure is due
to the curvature being too tight.

However some of the higher settings of resolution gave what looks like meshing
failure.

Also flat is about 2.5 times faster.

(The meshing time is approximately proportional to the fourth power of the
resolution.)


http://news.povray.org/web.5846a1f84d513ebce15d43a80@news.povray.org


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Isofunctions and meshes
Date: 6 Dec 2016 08:15:00
Message: <web.5846b8b0b9cec73d7b4f57df0@news.povray.org>
"John Greenwood" <joh### [at] john-greenwoodcouk> wrote:
> "omniverse" <omn### [at] charternet> wrote:
> > "John Greenwood" <joh### [at] john-greenwoodcouk> wrote:
> > That object to mesh stuff is fascinating, unfortunately I'm terrible with
> > meshes. And not so good with isosurfaces either. LOL
> >
> > Looks like you got a fair result. When I tried the in-pov converting from Chris
> > Young I was getting inner CSG surfaces found until changing from unions to
> > merge. Something I hadn't expected. No idea what could happen with isosurfaces
> > based on that.
> >
> > Wish you luck.
> >
> > Bob
>
> Thanks
>
> I meshed this shape with different settings for resolution. The values are shown
> under each example.
>
> isoSmooth was set to no. The failures seem to happen regardless but this gives
> an indication that in the first example, with resolution = 5, the failure is due
> to the curvature being too tight.
>
> However some of the higher settings of resolution gave what looks like meshing
> failure.
>
> Also flat is about 2.5 times faster.
>
> (The meshing time is approximately proportional to the fourth power of the
> resolution.)
>
>
> http://news.povray.org/web.5846a1f84d513ebce15d43a80@news.povray.org

Have you tried to set the recursion depth to 0 ?

Like this:

#declare Depth = 0;


I'm not able to see if the triangles are missing or if they are just dark. Can
you "see" through the openings where the triangles seem to be missing ?

--
Tor Olav
http://subcube.com


Post a reply to this message

From: Leroy
Subject: Re: Isofunctions and meshes
Date: 6 Dec 2016 14:05:01
Message: <web.58470aa3b9cec73dc6bb200e0@news.povray.org>
"John Greenwood" <joh### [at] john-greenwoodcouk> wrote:
> "Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> > "John Greenwood" <joh### [at] john-greenwoodcouk> wrote:
>
> >> can my function, which is a single closed surface, be turned into mesh?
> >
> > Perhaps you can find something useful in this thread:
> >
> > Subject: Isosurface Approximation macros rewrite
> > From: Tor Olav Kristensen
> > Date: 2008 February 22nd
> > Message: <47be20ab@news.povray.org>
> > Newsgroup: povray.binaries.scene-files
> >
> >
http://news.povray.org/povray.binaries.scene-files/thread/%3C47cc76fd@news.povray.org%3E/
> >
> > --
> > Tor Olav
> > http://subcube.com
>
> I have had a look and am floundering.
>
> An example would be worth ten thousand words.
>
> Could some kind person point me at an actual example of converting a simple
> function, such as:
>     function(x,y,z){sqrt(pow(x,2)+pow(y,2)+pow(z,2))-L)/r }
> into a mesh object?

You can make any POV object into a mesh using trace.
My Rounded Prisms makes a Mesh2 file. Its at
http://leroywhetstone.s5.com/Pages/PovFiles.html#Tools

Although it's not simple, The basic idea is.
You take a mesh(in my case a simple flat surface) put the points into an array
then trace each point and save the new mesh.


Post a reply to this message

From: John Greenwood
Subject: Re: Isofunctions and meshes
Date: 8 Dec 2016 06:35:01
Message: <web.584944a9b9cec73de15d43a80@news.povray.org>
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> "John Greenwood" <joh### [at] john-greenwoodcouk> wrote:
> > "omniverse" <omn### [at] charternet> wrote:
> > > "John Greenwood" <joh### [at] john-greenwoodcouk> wrote:

> > I meshed this shape with different settings for resolution. The values are shown
> > under each example.
> >
> > isoSmooth was set to no. The failures seem to happen regardless but this gives
> > an indication that in the first example, with resolution = 5, the failure is due
> > to the curvature being too tight.
> >
> > However some of the higher settings of resolution gave what looks like meshing
> > failure.
> >
> > Also flat is about 2.5 times faster.
> >
> > (The meshing time is approximately proportional to the fourth power of the
> > resolution.)
> >
> >
> > http://news.povray.org/web.5846a1f84d513ebce15d43a80@news.povray.org
>
> Have you tried to set the recursion depth to 0 ?
>
> Like this:
>
> #declare Depth = 0;

I have just tried this and the results are like a Picasso version of
Frankenstein's monster.

> I'm not able to see if the triangles are missing or if they are just dark. Can
> you "see" through the openings where the triangles seem to be missing ?

Yes they do seem to be missing and you can see through the holes. I have posted
an example to follow the last one


Post a reply to this message

From: John Greenwood
Subject: Re: Isofunctions and meshes
Date: 8 Dec 2016 07:35:00
Message: <web.58495284b9cec73de15d43a80@news.povray.org>
"Leroy" <whe### [at] gmailcom> wrote:
> "John Greenwood" <joh### [at] john-greenwoodcouk> wrote:
> > "Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> > > "John Greenwood" <joh### [at] john-greenwoodcouk> wrote:

> > >> can my function, which is a single closed surface, be turned into mesh?

> You can make any POV object into a mesh using trace.
> My Rounded Prisms makes a Mesh2 file. Its at
> http://leroywhetstone.s5.com/Pages/PovFiles.html#Tools
>
> Although it's not simple, The basic idea is.
> You take a mesh(in my case a simple flat surface) put the points into an array
> then trace each point and save the new mesh.

Interesting... a very limited case mesher, but I think what is needed is a
simple-to-use meshing engine.


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Isofunctions and meshes
Date: 8 Dec 2016 07:50:00
Message: <web.584956dcb9cec73d7b4f57df0@news.povray.org>
"John Greenwood" <joh### [at] john-greenwoodcouk> wrote:
> "Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
....
> > Have you tried to set the recursion depth to 0 ?
> >
> > Like this:
> >
> > #declare Depth = 0;
>
> I have just tried this and the results are like a Picasso version of
> Frankenstein's monster.

IIRC the resolution has to be raised considerable if you have no recursion.


> > I'm not able to see if the triangles are missing or if they are just dark. Can
> > you "see" through the openings where the triangles seem to be missing ?
>
> Yes they do seem to be missing and you can see through the holes. I have posted
> an example to follow the last one

Ok. I see.

I think that using recursion may lead to unwanted holes.


--
Tor Olav
http://subcube.com


Post a reply to this message

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

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