POV-Ray : Newsgroups : povray.general : Smooth level for smooth_triangle. Server Time19 May 2024 22:26:21 EDT (-0400)
 Smooth level for smooth_triangle. (Message 11 to 20 of 56)
 From: Bald Eagle Subject: Re: Smooth level for smooth_triangle. Date: 19 Nov 2023 16:00:00 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.655a765e84c692a31f9dae3025979125%40news.povray.org",
"headline": "Re: Smooth level for smooth_triangle.",
"dateCreated": "2023-11-19T21:00:00+00:00",
"datePublished": "2023-11-19T21:00:00+00:00",
"author": {
"@type": "Person",
"name": "Bald Eagle"
}
}
"GioSeregni" <gms### [at] hotmailcom> wrote:

> sure, last night I started with two faces, then three, then a cube (bad idea),

Well, it was a good idea, because it shows you what can happen  ;)

> I was thinking, for your idea, instead of the area, which means many operations,
> finding the center of the triangle, and comparing the size of the triangles
> using the center- 1 vertex distance.
> G.

Well, you can do whatever you like, but I'm not sure how much faster it will be,
or how much better it will be.

First you have to compute the center, and then you have to pick - what - the
maximum distance to 3 vertices?  What if you have 2 triangles that share the
only a single vertex?  |X|  Which of the 2 sides on the one triangle do you use
to scale the face normal by?

If you have vertices, A, B, and C, then you have vectors (A-B) and (C-B), and
the vector cross product of those will give you a vector perpendicular to the
surface (the face normal), AND it's length will be a scalar value proportional
to the surface area of the triangle, all in a single calculation.

What I usually do when experimenting with different methods, is either use a
#switch block to choose what method I'm using, or use macros with similar names
that do things a slightly different way.
#macro Method1 ()
#macro Method2 ()
#macro Method3 ()

and then I just change the name of what macro I'm calling to do the part of the
code where I'm doing the experimentation to see what will work best / fastest.

- BW
```
 From: Bald Eagle Subject: Re: Smooth level for smooth_triangle. Date: 20 Nov 2023 14:15:00 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.655baf1e84c692a31f9dae3025979125%40news.povray.org",
"headline": "Re: Smooth level for smooth_triangle.",
"dateCreated": "2023-11-20T19:15:00+00:00",
"datePublished": "2023-11-20T19:15:00+00:00",
"author": {
"@type": "Person",
"name": "Bald Eagle"
}
}
"GioSeregni" <gms### [at] hotmailcom> wrote:
> Hi all, first I apologize for my bad english.
> I finished now developing (basic version no color at this moment)  a small
> transformation tool from STL mesh, in the center, to mesh with smooth_triangles.
> But I have a problem. Too smooth. I thought that the length of the normal vector
> caused a gradation, but this is not the case, even if I reduce the length of the
> vectors the smoothness level remains the same. What am I doing wrong?
> Giovanni

Glassner, Andrew, Building Vertex Normals from an Unstructured Polygon List,
Graphics Gems IV, p. 60-73, code: p. 64-73, vert_norm/.
https://www.realtimerendering.com/resources/GraphicsGems/gemsiv/vert_norm/
```
 From: GioSeregni Subject: Re: Smooth level for smooth_triangle. Date: 20 Nov 2023 16:45:00 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.655bd2d784c692a35464b73e59126100%40news.povray.org",
"headline": "Re: Smooth level for smooth_triangle.",
"dateCreated": "2023-11-20T21:45:00+00:00",
"datePublished": "2023-11-20T21:45:00+00:00",
"author": {
"@type": "Person",
"name": "GioSeregni"
}
}
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "GioSeregni" <gms### [at] hotmailcom> wrote:
> > Hi all, first I apologize for my bad english.
> > I finished now developing (basic version no color at this moment)  a small
> > transformation tool from STL mesh, in the center, to mesh with smooth_triangles.
> > But I have a problem. Too smooth. I thought that the length of the normal vector
> > caused a gradation, but this is not the case, even if I reduce the length of the
> > vectors the smoothness level remains the same. What am I doing wrong?
> > Giovanni
>
> Glassner, Andrew, Building Vertex Normals from an Unstructured Polygon List,
> Graphics Gems IV, p. 60-73, code: p. 64-73, vert_norm/.
> https://www.realtimerendering.com/resources/GraphicsGems/gemsiv/vert_norm/

Thanks, but I my code with normals works fine, see my code and render pictures
above.
Furthermore, even if I am able to calculate the normals, in the binary STL files
to be converted, they are already present and available.
The question is about the level of the smooth.
I would like to get the effect of a smaller radius in the rounding illusion.
As Bald Eagle suggested I'm trying to work on the single "weight" of normals in
their average for each point  (which creates the smooth effect) , considering
the size of each triangle.
I hope I have explained myself, I have little command of English, and the
question is not very simple
Many Thanks!
G.
```
 From: GioSeregni Subject: Re: Smooth level for smooth_triangle. Date: 20 Nov 2023 16:55:00 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.655bd5a184c692a35464b73e59126100%40news.povray.org",
"headline": "Re: Smooth level for smooth_triangle.",
"dateCreated": "2023-11-20T21:55:00+00:00",
"datePublished": "2023-11-20T21:55:00+00:00",
"author": {
"@type": "Person",
"name": "GioSeregni"
}
}
For an excellent result the code must have at least 3 steps
1) (already done), calculation of the average of the normals affecting the
point.
2) Correcting the weight of the normals per point if they also come from
triangles with a large surface area
3) Corrective of the normals if the adjacent triangles have an inclination
between them that tends to approach 90 degrees

G.
```
 From: jr Subject: Re: Smooth level for smooth_triangle. Date: 21 Nov 2023 00:05:00 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.655c3a6384c692a3f11225116cde94f1%40news.povray.org",
"headline": "Re: Smooth level for smooth_triangle.",
"dateCreated": "2023-11-21T05:05:00+00:00",
"datePublished": "2023-11-21T05:05:00+00:00",
"author": {
"@type": "Person",
"name": "jr"
}
}
hi,

"GioSeregni" <gms### [at] hotmailcom> wrote:
> For an excellent result the code must have at least 3 steps
> 1) (already done), calculation of the average of the normals affecting the
> point.
> 2) Correcting the weight of the normals per point if they also come from
> triangles with a large surface area
> 3) Corrective of the normals if the adjacent triangles have an inclination
> between them that tends to approach 90 degrees

fwiw, my 'gts2pov' takes triangle area into account when calculating the
normals.  also just found mention of a 'stl2pov' software :
<https://news.povray.org/web.6156c51533af95845bd1b3ba6cde94f1%40news.povray.org>

<https://wiki.povray.org/content/User:Jr>

regards, jr.
```
 From: GioSeregni Subject: Re: Smooth level for smooth_triangle. Date: 21 Nov 2023 02:30:00 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.655c5bc784c692a35464b73e59126100%40news.povray.org",
"headline": "Re: Smooth level for smooth_triangle.",
"dateCreated": "2023-11-21T07:30:00+00:00",
"datePublished": "2023-11-21T07:30:00+00:00",
"author": {
"@type": "Person",
"name": "GioSeregni"
}
}
"jr" <cre### [at] gmailcom> wrote:
> hi,
>
> "GioSeregni" <gms### [at] hotmailcom> wrote:
> > For an excellent result the code must have at least 3 steps
> > 1) (already done), calculation of the average of the normals affecting the
> > point.
> > 2) Correcting the weight of the normals per point if they also come from
> > triangles with a large surface area
> > 3) Corrective of the normals if the adjacent triangles have an inclination
> > between them that tends to approach 90 degrees
>
> fwiw, my 'gts2pov' takes triangle area into account when calculating the
> normals.  also just found mention of a 'stl2pov' software :
> <https://news.povray.org/web.6156c51533af95845bd1b3ba6cde94f1%40news.povray.org>
>
> <https://wiki.povray.org/content/User:Jr>
>
>
> regards, jr.

Tx JR!
My code is already working from STL to POV even with the color subset of STL.
In fact I have to add the surface calculation to the loops from triangle to
smooth_triangle, I'll take a look at your system. But first I also want to
translate the color, as I already do with the triangles, dividing groups of
differently colored meshes. This way my translator will also become faster
because the loops are compact and short on small meshes.
(between different colors I don't want smooth).
In the center STL, on the left the current smooth routine, on the right the
simple triangle mesh. Thank you!
```

Attachments:

Preview of image 'clipboard01.png'

 From: Mr Subject: Re: Smooth level for smooth_triangle. Date: 21 Nov 2023 04:45:00 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.655c7b9b84c692a316086ed06830a892%40news.povray.org",
"headline": "Re: Smooth level for smooth_triangle.",
"dateCreated": "2023-11-21T09:45:00+00:00",
"datePublished": "2023-11-21T09:45:00+00:00",
"author": {
"@type": "Person",
"name": "Mr"
}
}
"GioSeregni" <gms### [at] hotmailcom> wrote:
> "jr" <cre### [at] gmailcom> wrote:
> > hi,
> >
> > "GioSeregni" <gms### [at] hotmailcom> wrote:
> > > For an excellent result the code must have at least 3 steps
> > > 1) (already done), calculation of the average of the normals affecting the
> > > point.
> > > 2) Correcting the weight of the normals per point if they also come from
> > > triangles with a large surface area
> > > 3) Corrective of the normals if the adjacent triangles have an inclination
> > > between them that tends to approach 90 degrees
> >
> > fwiw, my 'gts2pov' takes triangle area into account when calculating the
> > normals.  also just found mention of a 'stl2pov' software :
> > <https://news.povray.org/web.6156c51533af95845bd1b3ba6cde94f1%40news.povray.org>
> >
> > <https://wiki.povray.org/content/User:Jr>
> >
> >
> > regards, jr.
>
> Tx JR!
> My code is already working from STL to POV even with the color subset of STL.
> In fact I have to add the surface calculation to the loops from triangle to
> smooth_triangle, I'll take a look at your system. But first I also want to
> translate the color, as I already do with the triangles, dividing groups of
> differently colored meshes. This way my translator will also become faster
> because the loops are compact and short on small meshes.
> (between different colors I don't want smooth).
> In the center STL, on the left the current smooth routine, on the right the
> simple triangle mesh. Thank you!

I May be wrong but I don't believe the normals length will be taken into account
at all. I believe they are rather always 'normalized' (no pun) to a value of 1
and just their directions used. Some of the most valuable input may be from
Alain with all his technical POV knowledge. the only things that then would
change the apparent curvature of normals *globally* is the 'brilliance' keyword
value or more locally the slope normal pattern... but again all this needs to be
verified.
```
 From: jr Subject: Re: Smooth level for smooth_triangle. Date: 21 Nov 2023 05:30:00 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.655c869e84c692a3f11225116cde94f1%40news.povray.org",
"headline": "Re: Smooth level for smooth_triangle.",
"dateCreated": "2023-11-21T10:30:00+00:00",
"datePublished": "2023-11-21T10:30:00+00:00",
"author": {
"@type": "Person",
"name": "jr"
}
}
hi,

"GioSeregni" <gms### [at] hotmailcom> wrote:
> ...
> Tx JR!

welcome.  a visual to compare, the mesh is from the GTS home site.
<https://news.povray.org/web.610401e9687fa6155e0fed26cde94f1%40news.povray.org>

> My code is already working from STL to POV even with the color subset of STL.

ah, colour is something I ought to look into, too.  cheers.

regards, jr.
```
 From: Bald Eagle Subject: Re: Smooth level for smooth_triangle. Date: 21 Nov 2023 06:45:00 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.655c978784c692a31f9dae3025979125%40news.povray.org",
"headline": "Re: Smooth level for smooth_triangle.",
"dateCreated": "2023-11-21T11:45:00+00:00",
"datePublished": "2023-11-21T11:45:00+00:00",
"author": {
"@type": "Person",
"name": "Bald Eagle"
}
}
I tried a search of the NG to see what else there might be, these were the only
2 so far to catch my eye.

Maybe some small thing in there might trigger an idea, yet untested.

Warp:
https://news.povray.org/3cd536d5%40news.povray.org

jceddy:

- BW
```
 From: GioSeregni Subject: Re: Smooth level for smooth_triangle. Date: 21 Nov 2023 08:25:00 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.655caf7584c692a35464b73e59126100%40news.povray.org",
"headline": "Re: Smooth level for smooth_triangle.",
"dateCreated": "2023-11-21T13:25:00+00:00",
"datePublished": "2023-11-21T13:25:00+00:00",
"author": {
"@type": "Person",
"name": "GioSeregni"
}
}
"Bald Eagle" <cre### [at] netscapenet> wrote:
> I tried a search of the NG to see what else there might be, these were the only
> 2 so far to catch my eye.
>
> Maybe some small thing in there might trigger an idea, yet untested.
>
> Warp:
> https://news.povray.org/3cd536d5%40news.povray.org
>
> jceddy:
>
>
> - BW

Tx Jr and BW for the links, I use exactly the average..
They aren't true color
I use this code by STL (subset of colors)  to POV (truecolor)

r=STLface.descriptor AND 31744
r=r SHR 10
r=r*8
g=STLface.descriptor AND 992
g=g SHR 5
g=g*8
b=STLface.descriptor AND 31
b=b*8
POV_COLOR=b+(g*256)+(r*65536)

NOTE: this is my struct for STL's face

TYPE STL
numfacets As Long  '4 b then -> loop
nx        As Single   '4 b
ny        As Single
nz        As Single
x0        As Single
y0        AS Single
z0        As Single
x1        As Single
y1        As Single
z1        As Single
x2        As Single
y2        As Single
z2        As Single
descriptor As Short '2 b <--- end loop
END TYPE
DIM STLface AS STL
```