













Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The importance of surface texture in computer graphics and discusses two approaches to modeling intricate surface detail: explicit geometric representation and geometry + texture images. It also covers texture mapping, texturing polygonal models, and texturing with opengl.
Typology: Study notes
1 / 21
This page cannot be seen from the preview
Don't miss anything!














Objects in the real world have rich, detailed surface textures
Generated with Blue Moon Rendering Tools — www.bmrt.org
Approach #1: Explicit geometric representation
Approach #2: Geometry + texture images
Generally useful for skin, bricks, stucco, granite, …
Typically need to repeat texture over the object
Sample model from www.cyberware.com
Polygonal models don’t have a natural 2-D parameterization
For each vertex, we specify a texture coordinate
There are certain objects that are easy to parameterize
For a given object, we can often establish a mapping to one of these
During rasterization, we traverse the pixels of a triangle
What do we do with the contents of the texel?
d
Minification: 1 pixel covers multiple texels
Magnification: 1 texel covers multiple pixels
Texture
Surface
Screen
Here’s an example setup
This configures the texturing system to
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, width, height, 0,
GL_RGB, GL_UNSIGNED_BYTE, image);
When drawing, just assign texture coordinates to vertices
glBegin(GL_TRIANGLES);
glNormal3fv(n1);
glTexCoord2f(s1, t1);
glVertex3fv(v1);
glNormal3fv(n2);
glTexCoord2f(s2, t2);
glVertex3f(v2);
glNormal3fv(n3);
glTexCoord2f(s3, t3);
glVertex3fv(v3);
glEnd();
Instead of texture images, we can define texture volumes
Turns out to be a powerful technique
2-D parameterizations
First, there’s the obvious one: realistic surface detail
We can also support illumination precalculation
Texturing can also be handy for faking objects
to face the viewer (handy for things like trees)
And texturing is useful for level of detail management
For efficiency, we can use an image pyramid (mip–map)
256x256 128x128 64x64 32x
Image pyramids let us efficiently average large regions
k
x 2
k
texels
Fortunately, OpenGL can take care of most details
pyramid from base image
Basic texture mapping applies colors to surfaces
We’ll look at a couple of examples today
This is a method of playing a dirty trick on the human viewer
We want to add surface texture to an object
This is not directly supported by OpenGL
original normal
from bump map
n = n +! n
Texture maps are not (just) images
Texture maps are 2-D look-up tables of 3-vectors
Textures can encode any bivariate triple-valued function
We can do a lot with look-up tables!
Suppose we have some bivariate shading equation
We could shade a surface purely through texturing
Texture map serves as look-up table for our shading equation
( , ) color to shade given point
I s t
s t
Recall the Phong illumination model
We can write this as a bivariate function
max( ,( )) (max( , ))
n
a a d d s s
I = k I + 0 n! L k I + 0 r! v k I
where
n
a a d d s s
I s t k I sk I t k I
s
t
n L
r v
0! s = n " L # 1
t
r v
One approximation for the reflectance of skin
can also be written as a bivariate function
d d
I k I
n L
n L n v
where
d d
s
I s t k I
s t
s
t
n L
n v
0! s = n " L # 1
t
n v
Shade model with a linear blend of “warm” and “cool” colors
mixed with surface color
cool warm
I k k
L n L n
cool blue d blue
warm yellow d yellow
k k k k b
k k k k y y
.. ..
b y
! "
= 0 4 = 0 4
= 0 2 = 0 6
The Triumph of St. Ignatius
We can also use texturing to simulate reflections
appropriate reflected direction in the cube map
Fairly easy to generate
But not totally accurate
which the images were taken
Environment mapping maps reflection vectors to texture
Need a projection function for reflection vector
reflection vector r
viewing direction u
r !( s , t )
m x y z
z
2 2 2
Resulting texture coordinates:
x y
s t
m m
n
u
r =( x , y , z )
unit normal
unit viewing direction
unit reflected directio
n
ll in eye space!
n
u
r
Reflection vector:
r = u! 2 ( n " u ) n
OpenGL uses spherical projection
To use environment maps
glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
There is a natural mapping between these two
unit sphere unit cube