POV-Ray : Newsgroups : povray.general : Mesh rendering artifacts Server Time18 Apr 2024 12:08:47 EDT (-0400)
 Mesh rendering artifacts (Message 11 to 20 of 63)
 From: yesbird Subject: Re: Mesh rendering artifacts Date: 30 Jan 2023 10:45:00 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.63d7e4f8249f0076988cc0cb10800fb2%40news.povray.org",
"dateCreated": "2023-01-30T15:45:00+00:00",
"datePublished": "2023-01-30T15:45:00+00:00",
"author": {
"@type": "Person",
"name": "yesbird"
}
}
> What is your XY grid resolution for that mesh ?

50x50:
....
t = linspace (-8, 8, 50);
[x, y] = meshgrid (t, t);
r = sqrt (x .^ 2 + y .^ 2) + eps;
z = 18 * sin (r) ./ r;
s = surf(x,y,z, FaceColor = 'interp', EdgeColor = 'interp');
....

>
> How are you calculating the vertex normals and the vertex colors ?
>
Matlab do it for me)

> - And have you been careful to have the same clockwise or anticlockwise
> order of the vertices in all the triangles?
I will check it, thanks.

> If the problem persists after making sure that everything else is ok,
> you can try to divide each quadrilateral into two triangles along it's
> shortest diagonal. Alternatively you can divide it into two triangles
> according to which of the two ways of doing it deviates less from the
> surface (e.g. at the center of the quadrilateral).

May be it will help, but for this method I would like to stay sticked to
Matlab's generated geometry. Little bit late I will implement method that
completely replace 'surf' with POV-only techiques. I am sure, that it will work
much faster, et least.

Present implementation was only the first experiment, which helps me to start
working with POV and explore Matlab's geometry structures.
```
 From: yesbird Subject: Re: Mesh rendering artifacts Date: 30 Jan 2023 12:25:00 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.63d7fc76249f0076988cc0cb10800fb2%40news.povray.org",
"dateCreated": "2023-01-30T17:25:00+00:00",
"datePublished": "2023-01-30T17:25:00+00:00",
"author": {
"@type": "Person",
"name": "yesbird"
}
}
> What is your XY grid resolution for that mesh ?

50x50:
....
t = linspace (-8, 8, 50);
[x, y] = meshgrid (t, t);
r = sqrt (x .^ 2 + y .^ 2) + eps;
z = 18 * sin (r) ./ r;
s = surf(x,y,z, FaceColor = 'interp', EdgeColor = 'interp');
....

>
> How are you calculating the vertex normals and the vertex colors ?
>
Matlab do it for me)

> - And have you been careful to have the same clockwise or anticlockwise
> order of the vertices in all the triangles?
I will check it, thanks.

> If the problem persists after making sure that everything else is ok,
> you can try to divide each quadrilateral into two triangles along it's
> shortest diagonal. Alternatively you can divide it into two triangles
> according to which of the two ways of doing it deviates less from the
> surface (e.g. at the center of the quadrilateral).

May be it will help, but for this method I would like to stay sticked to
Matlab's generated geometry. Little bit late I will implement method that
completely replace 'surf' with POV-only techiques. I am sure, that it will work
much faster, et least.

Present implementation was only the first experiment, which helps me to start
working with POV and explore Matlab's geometry structures.
```
 From: Bald Eagle Subject: Re: Mesh rendering artifacts Date: 30 Jan 2023 14:05:00 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.63d8142d249f00761f9dae3025979125%40news.povray.org",
"dateCreated": "2023-01-30T19:05:00+00:00",
"datePublished": "2023-01-30T19:05:00+00:00",
"author": {
"@type": "Person",
"name": "Bald Eagle"
}
}
"yesbird" <nomail@nomail> wrote:

> I will play with vertex order as Tor suggested, but please take into account
> that effect is mostly visible on high elevation (along the vertical axis).

One of the easiest things to do when looking for "wrong" surface normals is to
use an interior_texture {} which will color the opposite face of the triangles a
different color.   Then you don't have to even look at the code - just look at
the triangles in the render.
```
 From: yesbird Subject: Re: Mesh rendering artifacts Date: 30 Jan 2023 14:35:00 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.63d81b22249f0076df04b5ff10800fb2%40news.povray.org",
"dateCreated": "2023-01-30T19:35:00+00:00",
"datePublished": "2023-01-30T19:35:00+00:00",
"author": {
"@type": "Person",
"name": "yesbird"
}
}
> One of the easiest things to do when looking for "wrong" surface normals is to
> use an interior_texture {} which will color the opposite face of the triangles a
> different color.   Then you don't have to even look at the code - just look at
> the triangles in the render.

Thanks for this tip, I will check surface with it !
```
 From: yesbird Subject: Re: Mesh rendering artifacts Date: 30 Jan 2023 14:55:00 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.63d81f6f249f0076df04b5ff10800fb2%40news.povray.org",
"dateCreated": "2023-01-30T19:55:00+00:00",
"datePublished": "2023-01-30T19:55:00+00:00",
"author": {
"@type": "Person",
"name": "yesbird"
}
}
"yesbird" <nomail@nomail> wrote:
> > One of the easiest things to do when looking for "wrong" surface normals is to
> > use an interior_texture {} which will color the opposite face of the triangles a
> > different color.   Then you don't have to even look at the code - just look at
> > the triangles in the render.
>
> Thanks for this tip, I will check surface with it !

..... but only if I will be able. Can't figure out how to push interior_texture
into texture_list, this way is not working:

smooth_triangle {<-8.00, -8.00, -1.51>, <0.19, 0.19, 0.96>,
<-8.00, -7.67, -1.62>, <0.07, 0.07, 1.00>,
<-7.67, -7.67, -1.64>, <-0.06, -0.06, 1.00>

#declare t1=texture { pigment {rgb<1.00, 0.66, 0.00>} finish {f} }
#declare t2=texture { pigment {rgb<1.00, 0.61, 0.00>} finish {f} }
#declare t3=texture { pigment {rgb<1.00, 0.61, 0.00>} finish {f} }

#declare it1=interior_texture  { pigment {rgb<0, 0, 0>} }
#declare it2=interior_texture  { pigment {rgb<0, 0, 0>} }
#declare it3=interior_texture  { pigment {rgb<0, 0, 0>} }

texture_list {t1 t2 t3}
texture_list {it1 it2 it3}
}
```
 From: jr Subject: Re: Mesh rendering artifacts Date: 30 Jan 2023 15:20:00 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.63d82561249f0076fbdc16836cde94f1%40news.povray.org",
"dateCreated": "2023-01-30T20:20:00+00:00",
"datePublished": "2023-01-30T20:20:00+00:00",
"author": {
"@type": "Person",
"name": "jr"
}
}
hi,

"yesbird" <nomail@nomail> wrote:
> ...
>        #declare it1=interior_texture  { pigment {rgb<0, 0, 0>} }
>        #declare it2=interior_texture  { pigment {rgb<0, 0, 0>} }
>        #declare it3=interior_texture  { pigment {rgb<0, 0, 0>} }

only one interior, per mesh.  insert just before the scale.
<https://wiki.povray.org/content/Reference:Interior_Texture>

regards, jr.
```
 From: jr Subject: Re: Mesh rendering artifacts Date: 30 Jan 2023 15:25:00 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.63d826b9249f0076fbdc16836cde94f1%40news.povray.org",
"dateCreated": "2023-01-30T20:25:00+00:00",
"datePublished": "2023-01-30T20:25:00+00:00",
"author": {
"@type": "Person",
"name": "jr"
}
}
oops, forgot.  you may need to make the object "hollow", too.

> only one interior, per mesh.  insert just before the scale.
> <https://wiki.povray.org/content/Reference:Interior_Texture>

<https://wiki.povray.org/content/Reference:Hollow_Object_Modifier>

regards, jr.
```
 From: yesbird Subject: Re: Mesh rendering artifacts Date: 30 Jan 2023 19:00:00 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.63d8594a249f0076df04b5ff10800fb2%40news.povray.org",
"dateCreated": "2023-01-31T00:00:00+00:00",
"datePublished": "2023-01-31T00:00:00+00:00",
"author": {
"@type": "Person",
"name": "yesbird"
}
}
> only one interior, per mesh.  insert just before the scale.
> <https://wiki.povray.org/content/Reference:Interior_Texture>
Thanks, I'v checked it - normals are normal.

It's strange: flat surface looks good, oposite to peaked.
```

Attachments:

Preview of image 'surface3.png'

 From: yesbird Subject: Re: Mesh rendering artifacts Date: 30 Jan 2023 19:05:00 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.63d85a46249f0076df04b5ff10800fb2%40news.povray.org",
"dateCreated": "2023-01-31T00:05:00+00:00",
"datePublished": "2023-01-31T00:05:00+00:00",
"author": {
"@type": "Person",
"name": "yesbird"
}
}
"yesbird" <nomail@nomail> wrote:
> > only one interior, per mesh.  insert just before the scale.
> > <https://wiki.povray.org/content/Reference:Interior_Texture>
> Thanks, I'v checked it - normals are normal.
Scene
```

Attachments:

 From: Bald Eagle Subject: Re: Mesh rendering artifacts Date: 30 Jan 2023 19:05:00 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.63d85a77249f00761f9dae3025979125%40news.povray.org",
"dateCreated": "2023-01-31T00:05:00+00:00",
"datePublished": "2023-01-31T00:05:00+00:00",
"author": {
"@type": "Person",
"name": "Bald Eagle"
}
}
So, I worked out my own scene, using your equation, storing the <x, f(r), z> in
a 2D array, analytically calculating the vertex normals using fast forward
differencing to get the tangents by numerically approximating the partial
derivatives, then taking the vector cross product, and then making a mesh with
smooth_triangles with per-vertex normals.

(After horribly botching that 5 times in a row, I got the normals, and therefore
the triangles all working nicely.)

No textures for any of the triangles.

mesh {
loop over arrays to make triangles
interior_texture
}

I get a much steeper curve than you do, so I don't know if there's some kind of
scaling going on somewhere in the process.

I hard-coded the pigment_map for the texture, but it could probably be
calculated from the HSV2RGB macro in colors.inc
```

Attachments: