|
Ray Tracing Projects |
|
Assignment 6: Image Texture Mapping |
Return to Ray Tracing
Assignment Overview
|
|
The previous assignment used automatically
generated procedural 3D textures to create the look of marble.
Same idea here, except that we map bit-mapped images onto
geometry. Spheres are fairly easy, provided that you want to
map the entire image to the entire sphere. Triangle meshes
require texture (u, v) coordinates at each vertex which map to
pixels in the texture image. Interpolation is done across
the triangle in order to "fill-in" between the vertices. I
used bi-linear interpolation between 4 adjacent pixels to smooth
the texture to remove pixilation.
Below are images of triangle meshes that
approximate spheres. The last "globe" image is actual sphere
geometry. I used the algorithm in the OpenGL "Red Book"
(Chapter 2) for sphere generation by icosahedron subdivision.
In my opinion, this subdivision looks better than the tetrahedron
subdivision described in Edward Angel's Interactive Computer
Graphics text.
|
|

Sphere Approximated by 80 Triangles
400x400 JPG converted from 500x500 PPM output
Total time to parse, build, render and write: 2.265 seconds.
|
|

Sphere Approximated by 320 Triangles
400x400 JPG converted from 500x500 PPM output
Total time to parse, build, render and write: 2.953 seconds.
|
|

Sphere Approximated by 5120 Triangles
400x400 JPG converted from 500x500 PPM output
Total time to parse, build, render and write: 4.328 seconds.
|
|

Texture Mapped Sphere
400x400 JPG converted from 500x500 PPM output
Total time to parse, build, render and write: 0.672 seconds.
|
|
Pool Anyone?
Ok, so I couldn't resist the temptation to try
and make something that looks real. Since I only knew how to
texture map spheres I decided pool would be ideal. I think
we do motion blur later, so it'll be nice to get back to this
model then. The texture maps were created in Adobe Photoshop
from digital images of real pool balls and a real pool
table surface (courtesy of my brother Jonathan). Yes,
I realize that the stripe of the 13 ball is a little off, but
do you have any idea how hard it was to create that image?
|
|

Texture Mapped Objects
JPG converted from 700x500 PPM output
|
|
Problem and Resolution:
Tessellated Texture Coordinates
The earth images above that you're seeing are
focused on North America for a reason (and it's not that I just
favor that continent): the back sphere...where the texture
wraps around had a problem. My model file contains the (u,v)
texture coordinates for each triangle. These coordinates are
generated in the same manner that the (u,v) coordinates for a
texture mapped sphere are generated. Values are in [0,1].
The problem with a tessellated object is that if a triangle has
coordinates that "wrap around" (i.e. the u coordinate goes from,
e.g., 0.9 to 0.1) we don't actually want all the texture between
0.1 and 0.9...which is the way the renderer sees it. The
renderer has a way to wrap around, but it needs a (u, v) outside
[0,1] to do so. The solution was to modify my tessellated
sphere generator, detect when this situation occurred, and add 1.0
to the value that should wrap around. Below are cropped
images of the 'back' of the tessellated Earth image, before
and after.
|
|

Incorrect Texture Coordinates
|
|

Corrected Texture Coordinates
|
|
 |
 |
 |
|
email
at jasonwaltman
dot com |
 |
|
(c) 2000-2007 jason waltman |
|
|