POV-Ray : Newsgroups : povray.general : What's going on with this mesh2? Server Time
15 Nov 2024 03:22:17 EST (-0500)
  What's going on with this mesh2? (Message 1 to 6 of 6)  
From: Slime
Subject: What's going on with this mesh2?
Date: 24 Dec 2004 20:06:40
Message: <41ccbd20@news.povray.org>
Here is a simple mesh, made of two triangles. The mesh has a single
normal_vector, which is assigned to each vertex of each face. I would think
this would mean that the faces would take on that normal at every point, and
be shaded in the same way. However, the faces are shaded differently:

camera {
 location <3,3,-5>
 look_at 0
}

light_source {
 <-5,5,-5>*9999
 rgb .7
}

mesh2 {
 vertex_vectors {
  4,
  <0,0,0>,x,z,x+z+y
 }
 normal_vectors {
  1,
  y
 }
 face_indices {
  2,
  <0,1,2>,<1,3,2>
 }
 normal_indices {
  2,
  <0,0,0>,<0,0,0>
 }
 pigment {rgb 1}
}

Am I doing something wrong, or what's going on here?

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: Tim Nikias
Subject: Re: What's going on with this mesh2?
Date: 24 Dec 2004 22:30:26
Message: <41ccded2@news.povray.org>
The second triangle (the one using the x+y+z corner) is at a different angle
towards the lightsource and thus gets lit differently. You should try
brilliance 0 to see if that changes anything. All this is just a guess based
on the code, not an actual render.

Regards,
Tim

-- 
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>


Post a reply to this message

From: Slime
Subject: Re: What's going on with this mesh2?
Date: 24 Dec 2004 22:46:12
Message: <41cce284@news.povray.org>
> The second triangle (the one using the x+y+z corner) is at a different
angle
> towards the lightsource and thus gets lit differently.

Well yeah. But since I'm assigning normals to its vertices, I'm expecting
those to be used instead of the true normal of the surface.

And since I'm assigning them all the normal y (<0,1,0>), I'm expecting the
surface to be shaded as though it were along the X-Z plane, regardless of
where it actually is.

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: Mike Williams
Subject: Re: What's going on with this mesh2?
Date: 25 Dec 2004 00:51:31
Message: <SxXcQEAT$PzBFw35@econym.demon.co.uk>
Wasn't it Slime who wrote:
>> The second triangle (the one using the x+y+z corner) is at a different
>angle
>> towards the lightsource and thus gets lit differently.
>
>Well yeah. But since I'm assigning normals to its vertices, I'm expecting
>those to be used instead of the true normal of the surface.
>
>And since I'm assigning them all the normal y (<0,1,0>), I'm expecting the
>surface to be shaded as though it were along the X-Z plane, regardless of
>where it actually is.

There's something quite odd going on.

Shifting one of the normals by one part in a hundred thousand causes it
to behave as you would expect, with both triangles being equally bright.
This suggests to me that you're not doing anything wrong, and that it is
POV that is behaving oddly.

camera {
 location <3,3,-5>
 look_at 0.5
 angle 20
}

light_source {
 <-5,5,-5>*9999
 rgb .7
}

mesh2 {
 vertex_vectors {
  4,
  <0,0,0>,x,z,x+z+y
 }
 normal_vectors {
  2,
  y,
  y+0.00001             // Modified normal
 }
 face_indices {
  2,
  <0,1,2>,<1,3,2>
 }
 normal_indices {
  2,
  <0,0,0>,<0,1,0>       // One point uses the modified normal
 }
 pigment {rgb 1}
}

I've not looked at the source, but I vaguely seem to remember something
about POV using different (faster) code for triangles that it considers
to be flat. I guess what might be happening is that POV spots that all
three normals are the same and therefore treats both triangles as being
flat. This works correctly for the first face because the normals are
perpendicular to the face, but it doesn't work for the second face
because they're not. Tweaking one or two of the normals slightly forces
POV to skip the optimisation and use the actual smooth triangle
processing.

I don't know if I'd call this a bug, because a face with three equal
normals that are not perpendicular to the face is physically
unrealistic.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Slime
Subject: Re: What's going on with this mesh2?
Date: 26 Dec 2004 00:25:22
Message: <41ce4b42@news.povray.org>
> I've not looked at the source, but I vaguely seem to remember something
> about POV using different (faster) code for triangles that it considers
> to be flat. I guess what might be happening is that POV spots that all
> three normals are the same and therefore treats both triangles as being
> flat.

That would make sense.

> I don't know if I'd call this a bug, because a face with three equal
> normals that are not perpendicular to the face is physically
> unrealistic.

True, but then, any surface with normals that aren't perpendicular to it at
all is unrealistic - including the average smooth triangle. I know this
example is slightly odd, but I hope the developers would agree that this
isn't the best way for POV-Ray to behave in this situation. The actual code
in which I discovered this had normals which were pretty close to the true
normals of the triangles. I had two adjacent triangles which were close to
parallel but not quite, and I wanted them to appear parallel by assigning
normals like this.

It's also unlikely but possible that this situation could come up in a
normal smooth triangle mesh outputted by a modeller.

If your assessment is correct, then the problem could probably be avoided by
evaluating the dot product of the supplied normals and the true normal, and
skipping the optimization if the dot product is less than 1-epsilon.

Anyway, thanks for the workaround, it will probably help me solve my
problem.

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: Shay
Subject: Re: What's going on with this mesh2?
Date: 26 Dec 2004 11:13:20
Message: <41cee320@news.povray.org>
Slime wrote:

Triangles (in a mesh) with the same normal on every vertex are treated 
as flat triangles. The only solutions are to change your mesh to a union 
of triangles or very slightly change one of the normals of each 
triangle. Not one of my favorite features.

  -Shay


Post a reply to this message

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