POV-Ray : Newsgroups : povray.general : Smooth normals for mesh2 objects Server Time
28 Dec 2024 23:10:22 EST (-0500)
  Smooth normals for mesh2 objects (Message 1 to 10 of 21)  
Goto Latest 10 Messages Next 10 Messages >>>
From: David Given
Subject: Smooth normals for mesh2 objects
Date: 6 Dec 2013 08:26:55
Message: <52a1d09f$1@news.povray.org>
Is there a way to get Povray to automatically calculate smoothed normals
for a mesh2?

I'm generating huge meshes from an external procedural terrain
generator. The generator assumes that the renderer doesn't need explicit
normals, so not only does it not write them but it lacks the
functionality internally to go from a vertex to the facets containing
the vertex. So adding support for calculating smoothed normals is going
to be non-trivial.

Most other renderers I've looked at have an option to do this
automatically. Does Povray?

-- 
┌─── dg@cowlark.com ─────
http://www.cowlark.com ─────
│ "There does not now, nor will there ever, exist a programming
│ language in which it is the least bit hard to write bad programs." ---
│ Flon's Axiom


Post a reply to this message

From: Warp
Subject: Re: Smooth normals for mesh2 objects
Date: 6 Dec 2013 09:09:49
Message: <52a1daad@news.povray.org>
David Given <dg### [at] cowlarkcom> wrote:
> Is there a way to get Povray to automatically calculate smoothed normals
> for a mesh2?

Currently, no.

(Such a feature might be added in the future, either as a direct feature,
or by enhancing the language so that it could be easily written as a
script.)

-- 
                                                          - Warp


Post a reply to this message

From: Le Forgeron
Subject: Re: Smooth normals for mesh2 objects
Date: 6 Dec 2013 09:49:58
Message: <52a1e416$1@news.povray.org>
Le 06/12/2013 15:09, Warp a écrit :
> David Given <dg### [at] cowlarkcom> wrote:
>> Is there a way to get Povray to automatically calculate smoothed normals
>> for a mesh2?
> 
> Currently, no.

And the real tricky question is: how do you weight the various normals
at a vertex ?
So far I came with at least 4 different ways.

And for information: mesh2 is only a syntax, mesh & mesh2 are the same
internal object inside povray.
(yet, mesh2 is parsed much faster when it becomes long)

> 
> (Such a feature might be added in the future, either as a direct feature,

Done as a direct feature: smooth{...}
Illustration at:
http://wiki.povray.org/content/User:Le_Forgeron#smooth

Source code at:
https://bitbucket.org/LeForgeron/hgpovray

> or by enhancing the language so that it could be easily written as a
> script.)
> 


-- 
Just because nobody complains does not mean all parachutes are perfect.


Post a reply to this message

From: clipka
Subject: Re: Smooth normals for mesh2 objects
Date: 6 Dec 2013 11:44:14
Message: <52a1fede$1@news.povray.org>
Am 06.12.2013 14:26, schrieb David Given:
> Is there a way to get Povray to automatically calculate smoothed normals
> for a mesh2?
>
> I'm generating huge meshes from an external procedural terrain
> generator. The generator assumes that the renderer doesn't need explicit
> normals, so not only does it not write them but it lacks the
> functionality internally to go from a vertex to the facets containing
> the vertex. So adding support for calculating smoothed normals is going
> to be non-trivial.

POV-Ray has essentially the same problem: While it does know which 
vertices belong to a given facet, it would need an exhaustive search of 
the facets list to figure out which faces meet at a given vertex.

One thing you might do is first render the non-smoothed mesh in an 
orthographic scene with a gradient pattern applied, giving you a height 
map image; you can then feed that image into a smoothed height field.


Post a reply to this message

From: Warp
Subject: Re: Smooth normals for mesh2 objects
Date: 6 Dec 2013 12:47:31
Message: <52a20db3@news.povray.org>
Le_Forgeron <lef### [at] freefr> wrote:
> And the real tricky question is: how do you weight the various normals
> at a vertex ?
> So far I came with at least 4 different ways.

Well, the most common way is that, for each vertex, you take the normal
vectors of all the triangles that share that vertex, and calculate their
weighted average, the weight factor being the area of the triangle.
(This works better than just a regular average because it gives a smoother
result with meshes containing triangles of very differing sizes.)

Of course mesh models often contain sharp edges. It's naturally impossible
to know which edges are supposed to be sharp and which smooth because that
information is lost, but the algorithm can make an educated guess by
simply considering the edge between two triangles to be sharp if the
angle between the normals of those triangles is larger than a threshold
(which can be user-specified.)

Vertices at sharp edges/corners naturally require for two or more normals
to be created (one for each set of triangles that's on one side of the
sharp edge.)

-- 
                                                          - Warp


Post a reply to this message

From: Samuel Benge
Subject: Re: Smooth normals for mesh2 objects
Date: 6 Dec 2013 13:15:01
Message: <web.52a21377936fb32d143e08e80@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> POV-Ray has essentially the same problem: While it does know which
> vertices belong to a given facet, it would need an exhaustive search of
> the facets list to figure out which faces meet at a given vertex.

Well how did the subdivision patch do it, then? As I recall it was very fast, at
both subdivision and automatically calculating vertex normals. (I really miss
that patch!)

Sam


Post a reply to this message

From: MichaelJF
Subject: Re: Smooth normals for mesh2 objects
Date: 6 Dec 2013 13:40:00
Message: <web.52a21956936fb32d25aaf9de0@news.povray.org>
David Given <dg### [at] cowlarkcom> wrote:
> Is there a way to get Povray to automatically calculate smoothed normals
> for a mesh2?
>
> I'm generating huge meshes from an external procedural terrain
> generator. The generator assumes that the renderer doesn't need explicit
> normals, so not only does it not write them but it lacks the
> functionality internally to go from a vertex to the facets containing
> the vertex. So adding support for calculating smoothed normals is going
> to be non-trivial.
>
> Most other renderers I've looked at have an option to do this
> automatically. Does Povray?
>
If the mesh can be saved as obj and is not to large than PoseRay may be an
option to (re)calculate normals and save the object as pov-source. PoseRay
provides some options to calculate the normals and you have a preview. But IIRC
the grid can not be to large.

Best regards,
Micahel


Post a reply to this message

From: Jaime Vives Piqueres
Subject: Re: Smooth normals for mesh2 objects
Date: 6 Dec 2013 14:39:06
Message: <52a227da@news.povray.org>

> David Given <dg### [at] cowlarkcom> wrote:
>> Is there a way to get Povray to automatically calculate smoothed normals
>> for a mesh2?
>>
> If the mesh can be saved as obj and is not to large than PoseRay may be an
> option to (re)calculate normals and save the object as pov-source. PoseRay
> provides some options to calculate the normals and you have a preview. But IIRC
> the grid can not be to large.
>

   IIRC, Poseray will even take a mesh2 in POV-Ray format...

--
jaime


Post a reply to this message

From: clipka
Subject: Re: Smooth normals for mesh2 objects
Date: 6 Dec 2013 14:52:06
Message: <52a22ae6$1@news.povray.org>
Am 06.12.2013 19:12, schrieb Samuel Benge:
> clipka <ano### [at] anonymousorg> wrote:
>> POV-Ray has essentially the same problem: While it does know which
>> vertices belong to a given facet, it would need an exhaustive search of
>> the facets list to figure out which faces meet at a given vertex.
>
> Well how did the subdivision patch do it, then? As I recall it was very fast, at
> both subdivision and automatically calculating vertex normals. (I really miss
> that patch!)

I don't know that patch in detail, but it might have added extra data 
structures to keep track of the information required.


Post a reply to this message

From: David Given
Subject: Re: Smooth normals for mesh2 objects
Date: 6 Dec 2013 17:11:16
Message: <52a24b84$1@news.povray.org>
On 06/12/13 16:44, clipka wrote:
[...]
> One thing you might do is first render the non-smoothed mesh in an
> orthographic scene with a gradient pattern applied, giving you a height
> map image; you can then feed that image into a smoothed height field.

I'm modelling entire planets, which are unfortunately round, so the
heightfield primitive isn't much use to me. I've previously been using
isosurfaces but they're just too horrifically painfully slow,
particularly if I want to avoid render artifacts. Going for a polygon
mesh is a new improved system to try and avoid all that.

One day someone's going to come up with a way of storing efficient,
interpolatable spherical heightmap data without the distortion involved
in forcing it into a 2D matrix...

-- 
┌─── dg@cowlark.com ─────
http://www.cowlark.com ─────
│ "There does not now, nor will there ever, exist a programming
│ language in which it is the least bit hard to write bad programs." ---
│ Flon's Axiom


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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