|
Q:
What steps you think you completed correctly (assign yourself
a grade based on the scale below)
A: I have completed the Intersect and IntersectP method for
class Heightfield. They use the fast grid traversal algorithm
we talked in class. The Intersect routine is also able to return
a reasonable u, v parametric coordinate for texture mapping;
and it's able to do normal interpolation across triangles so
that the result looks smoother. I have tested the performance
of my implementation and I think the speed is substantially
faster than the original. (Usually takes 1/4 to 1/5 of the time
taken by the original implementation)
Q:
Links to your modified heightfield.cc file
A: Here.
Q:
An image (of your choice) showing your heightfield intersector
in all its glory
A: Here. (After Contrast Enhancing:
here)
Q:
A description of the algorithm you used to intersect heightfields,
interpolate normals, and anything else interesting you encountered
along your implementation. Please be brilliant but brief.
A: To intersect height field, I have used the fast grid traversal
algorithm we talked in class. At initialization, the bounding
box of the whole height field is computed; together, the bounding
boxes for each grid (formed by 4 adjacent points) are also computed
for accelerate the speed. When Intersect is called, a ray-bounding
box intersection is performed and if they intersect, the first
hit point will be the starting point for grid traversal. (Here
only x and y values are used for traversal because we can think
of the ray as projected onto x-y plane) For processing a grid,
a ray-bounding box intersection is called to check if the ray
intersect the current grid. If so, ray-triangle intersection
is performed on the two triangles inside the current grid. If
intersection is detected, it returns; otherwise, it traverses
to the next grid until ray is outside the heighfield.
Interpolation
of normals are calculated inside ray-triangle intersection:
using the barycentric coordinate of intersection point as weights,
a weighted average is done on the normals of three triangle
vertices. (n = b0*n0 + b1*n1 + b2*n2) And vertex normal is pre-calculated
and stored in an array. u,v parametric coordinate is also calculated
using the weighted average. (u,v) of the three triangle vertices
happen to be their (x,y) coordinate since the width and height
of heightfield is normalized to [0,1]. After interpolating normals,
the S and T vector at DifferentialGeometry class should also
be re-calculated to maintain the relationship between N, S,
T. Also, at mesh silhouette, interpolated normals might be negative
so it should be corrected, otherwise some black holes will appear
at silhouette. (I 'overheard' this from Greg)
|