|
|
Tor Olav Kristensen <tor### [at] onlineno> wrote:
> Hmmm... I don't know how POV-Ray calculates this.
> But IIRC ABX once "proved" with an image example
> that if the area of the triangles are used to
> scale the normal vectors for each triangle, then
> it produces quite "smooth shading" results for a
> mesh.
We have to make a distinction between normals at triangle vertices and
normals inside triangles (which are calculated internally by POV-Ray).
The normals at the vertices of the triangles are user-defined and thus
whatever the user wants them to be.
The normals inside the triangle are calculated by POV-Ray by interpolating
the vertex normals.
The normal vector at any point in the triangle is the weigthed average
of the normals at the vertices, where the weight factor for each normal is
the distance of the point from that normal. At the edge of the triangle the
normal at any point is the weigthed average of the two normals at the two
vertices of that edge.
In this special case, where we need the normal vector at the point X and
we want the result to be smooth, we can't set X to whatever we like, but
we have to set it to what POV-Ray calculates as the normal vector of triangle
A at point X. If you set the normal vectors at X for triangles B and C to
*anything* else than what POV-Ray calculates for triangle A at the point X,
you will not get smooth lighting.
This is the crucial thing to understand in this.
As said before, the normal vector of the triangle A at the point X is
the weighted average of the two vertex normals (which I marked as y and z),
where the weigth factor is the distance of X from them.
I don't know what is the *exact* formula (eg. I don't know if POV-Ray
normalizes the two vertex normals or not before calculating the weighted
average), but it shouldn't be too complicated.
--
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}// - Warp -
Post a reply to this message
|
|