
An Interactive Introduction to OpenGL
Programming
1
Texture Mapping
Texture Mapping
Thanks to Ed Angel, UNM
Thanks to Ed Angel, UNM
2
Texture Mapping
Texture Mapping
•
•The soup tin is easily described by pasting a label on the
The soup tin is easily described by pasting a label on the
plain cylinder
plain cylinder
•
•Texture mapping
Texture mapping associates the color of a po int with the
associates the color of a point with the
color in an image: the
color in an image: the texture
texture
•Soup tin: Each point on the cylinder get the label’s color
•
•Question to address: Which point of the texture do we
Question to address: Which point of the texture do we
use for a given point on the surface?
use for a given point on the surface?
•
•Establish a
Establish a mapping
mapping from surface points to image points
from surface points to image points
•Different mappings are common for different shapes
•We will, for now, just look at triangles (polygons)
3
Example Mappings
Example Mappings
4
•Apply a 1D, 2D, or 3D image to geometric
primitives
•Uses of Texturing
•simulating materials
•reducing geometric complexity
•image warping
•reflections
•
•Apply a 1D, 2D, or 3D image to geometric
Apply a 1D, 2D, or 3D image to geometric
primitives
primitives
•
•Uses of Texturing
Uses of Texturing
•simulating materials
•reducing geometric complexity
•image warping
•reflections
Texture
Mapping
Texture
Mapping CPU
CPU DL
DL
Poly.
Poly. Per
Vertex
Per
Vertex
Raster
Raster Frag
Frag FB
FB
Pixel
Pixel Texture
Texture
5
Texture Mapping
Texture Mapping
s
t
x
y
z
image
geometry screen
6
Texture Interpolation
Texture Interpolation
•
•Specify where the
Specify where the
vertices in world
vertices in world
space are mapped to
space are mapped to
in texture space
in texture space
•
•Linearly interpolate
Linearly interpolate
the mapping for other
the mapping for other
points in world space
points in world space
•Straight lines in world
space go to straight lines
in texture space
Texture map
s
t
Triangle in
world space