Make sure that the normal at each triangle vertex is set properly.
The normal at a vertex should NOT be computed as the normal to the triangle which
contains the vertex.
If you do that, then the color across each triangle will be uniform.
Rather, the normal at a given vertex is calculated as the average of the normals to
all the neighboring
triangles that meet at the vertex. For HCP meshes, six triangles will be averaged,
except
at edges. It's convenient to use a weighted average of the triangle normals at each
vertex.
The weighting is according to the area of each triangle. For each triangle (with
vertices a, b and c) meeting at a vertex c, take the cross product (a - c)x(b-c) to
obtain a vector normal
to the triangle and of length proportional to the triangle area. Sum these (usually) 6
vectors
to obtain the weighted average normal. (Make sure that the cross products for all the
neighboring triangles are calculated with the same "handedness", e.g. the right-hand
rule.)
You can then normalize this vector to length unity
if you wish. Using this approach, the normals at each vertex of a given triangle will
generally differ, and continuous shading variation will be seen across each triangle.
The triangle
artifacts of the mesh will virtually disappear from the rendered image of the surface.
Kostantinos Rekalidis wrote:
> Hi all
> I have a problem here.
> I made a shape3d.The geometry of this shape consist of a lot of triangles, which
>their vertices have differend colors. When i load that shape the gouraud shading of
>that shape apply in every triangle seperately and not in the whole shape.How can i do
>that?
>
> I will be very grateful if anyone know that and answer to me
>
> bye
>
> p.s Sorry for my English and if u ddint understand what i am tring to say plz send
>me an e-mail.
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff JAVA3D-INTEREST". For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".