Thanks for this valuable information.
The area weighting scheme, where un-normalized cross-products are summed, is
real slick.
And faster than the un-weighted approach.
- Jim Robertson
-----Original Message-----
From: Discussion list for Java 3D API
[mailto:[EMAIL PROTECTED]]On Behalf Of Mark Hood
Sent: Tuesday, November 21, 2000 9:51 PM
To: [EMAIL PROTECTED]
Subject: Re: [JAVA3D] Gouraud shading problem
> Date: Tue, 21 Nov 2000 17:03:45 -0600
> From: James Robertson <[EMAIL PROTECTED]>
>
> I'll obtain a normal by averaging the normals to the 6 triangles that
> surround the point.
>
> Since I'm new to 3D graphics, could anyone tell me whether this is
something
> that is commonly done? Are there more sophisticated techniques (like
> weighting)? Or am I completely missing the boat?
You're doing the standard thing.
Normal averages can also be weighted according to the surface areas of the
triangles from which they're derived. You can do this easily by computing
the
normals of all triangles sharing a vertex from the cross product of two
edges
of each triangle, adding all the normals together, and then normalizing the
result to unit length by dividing its components by its length. This works
because the length of the vector cross product of two edges of a triangle is
half of its area.
For example, given an array of vertices, a corresponding array of vertex
normals initialized to (0, 0, 0), and triangles defined by indices into the
vertex array:
for each triangle
compute the vector cross product of two of its edges
add the vector cross product to the accumulated normals at each its
vertices
for each vertex
normalize the corresponding normal vector sum to unit length
Be sure to to multiply the edges in the order corresponding to the order of
the
vertices to avoid cross products pointing in the wrong direction; e.g.,
given a
triangle defined by points a, b, c in that order, compute the cross product
as
(b-a)X(c-b) or (c-b)X(a-c) or (a-c)X(b-a) or (b-a)X(c-a) or (c-b)X(a-b) or
(a-c)X(b-c).
There are also techniques which look at threshold angles between triangles
to
determine if the angle is too steep to average the normals, which allows
"hard"
edges between triangles at the expense of creating more vertices.
The GeometryInfo utility class can do all this for you.
-- Mark Hood
===========================================================================
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".