Texturing and Surface Detail: Modeling Complex Surface Textures in Computer Graphics, Study notes of Computer Graphics

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

Pre 2010

Uploaded on 03/16/2009

koofers-user-xty-2
koofers-user-xty-2 🇺🇸

8 documents

1 / 21

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
The Importance of Surface Texture
Objects in the real world have rich, detailed surface textures
to produce believable scenes, we must replicate this detail
uniformly colored surfaces only get us so far
Generated with Blue Moon Rendering Tools — www.bmrt.org
How Do We Model Intricate Surface Detail?
Approach #1: Explicit geometric representation
actual polygons that model all the surface variations
up to some finest level of detail
may generate a lot of polygons
Approach #2: Geometry + texture images
geometry only describes the general shape of the object
paste an image onto the wall to give the appearance of brick
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15

Partial preview of the text

Download Texturing and Surface Detail: Modeling Complex Surface Textures in Computer Graphics and more Study notes Computer Graphics in PDF only on Docsity!

The Importance of Surface Texture

Objects in the real world have rich, detailed surface textures

  • to produce believable scenes, we must replicate this detail
  • uniformly colored surfaces only get us so far

Generated with Blue Moon Rendering Tools — www.bmrt.org

How Do We Model Intricate Surface Detail?

Approach #1: Explicit geometric representation

  • actual polygons that model all the surface variations
  • up to some finest level of detail
  • may generate a lot of polygons

Approach #2: Geometry + texture images

  • geometry only describes the general shape of the object
  • paste an image onto the wall to give the appearance of brick

Often We Use Simple Patterns

Generally useful for skin, bricks, stucco, granite, …

Typically need to repeat texture over the object

  • must make sure there are no seams when texture is tiled

Or Given a Model and a Single Texture

Sample model from www.cyberware.com

Texturing Polygonal Models

Polygonal models don’t have a natural 2-D parameterization

  • we need to create one

For each vertex, we specify a texture coordinate

  • a ( u,v ) pair that maps that point into the texture image
  • a triangle on the surface will be mapped to a triangle in texture
  • can interpolate texture coordinates over the triangle
  • note that the size of the triangle may be quite different

Texturing with Intermediate Surfaces

There are certain objects that are easy to parameterize

  • spheres and cylinders are good examples

For a given object, we can often establish a mapping to one of these

  • this implicitly provides a parameterization of the surface

Texturing and Rasterization

During rasterization, we traverse the pixels of a triangle

  • at each pixel we interpolate the correct texture coordinate
  • and we retrieve the corresponding texel (texture element)

What do we do with the contents of the texel?

  • color — use it to fill in the current pixel
  • reflectance — coefficient for illumination equation (e.g., k

d

  • transparency — an alpha value
  • and many others, some of which we’ll discuss next time

Minification & Magnification

Minification: 1 pixel covers multiple texels

Magnification: 1 texel covers multiple pixels

Texture

Surface

Screen

Texturing with OpenGL

Here’s an example setup

This configures the texturing system to

  • combine (modulate) the texture color with the surface color
  • wrap texture coordinates around outside unit square
  • linearly average texels when “magnifying” and “minifying”

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);

Texturing with OpenGL

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();

Solid Texture

Instead of texture images, we can define texture volumes

  • create a 3-D parameterization ( u,v,w ) for the texture
  • map this onto the object
  • the easiest parameterization ( u,v,w ) = ( x,y,z )

Turns out to be a powerful technique

  • for procedural generation
  • more readily applies to implicit surfaces
  • and other surfaces without natural

2-D parameterizations

Some Texturing Applications

First, there’s the obvious one: realistic surface detail

  • paste a fur, marble, face scan, … on a surface

We can also support illumination precalculation

  • suppose we precompute some expensive lighting effects
    • soft shadows, indirect light (e.g., radiosity)
  • can hard code this lighting into texture maps

Texturing can also be handy for faking objects

  • billboards — place image on a polygon which always rotates

to face the viewer (handy for things like trees)

  • sprites used in video games are a similar idea

And texturing is useful for level of detail management

  • can decouple resolution of texture from resolution of surface

Texture Antialiasing

For efficiency, we can use an image pyramid (mip–map)

  • base of pyramid is the original image (level = 0)
  • level 1 is the image down-sampled by a factor of 2
  • level 2 is down-sampled by a factor of 4, and so on
  • requires that original dimensions be a power of 2
  • and it’s not too big: 4/3 the size of the original image

256x256 128x128 64x64 32x

Antialiasing with Image Pyramids

Image pyramids let us efficiently average large regions

  • each texel in upper levels covers many base texels
    • at level k they are the average of 2

k

x 2

k

texels

  • can quickly assemble appropriate texels for averaging

Fortunately, OpenGL can take care of most details

  • gluBuild2DMipmaps() — automatically generate

pyramid from base image

  • control behavior with glTexParameter()
  • OpenGL handles all filtering details during rasterization

Mapping More than Color

Basic texture mapping applies colors to surfaces

  • but the method is much more general than this
  • can be used to map wide range of data onto surfaces
  • although not necessarily supported by OpenGL

We’ll look at a couple of examples today

  • bump mapping
  • normal mapping
  • displacement mapping

Bump Mapping

This is a method of playing a dirty trick on the human viewer

  • perception of shape is determined by shading
  • which is determined by surface normal

We want to add surface texture to an object

  • start with a smooth surface (with few polygons)
  • interpret the 3 channels of each texel as a vector
  • use this vector to perturb the surface normal

This is not directly supported by OpenGL

original normal

from bump map

n = n +! n

Texture Maps as Lookup Tables

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!

Texture Shading

Suppose we have some bivariate shading equation

We could shade a surface purely through texturing

  • precompute values of I in a texture map
  • turn off lighting
  • at each vertex, compute ( s , t ) and emit as texture coordinate

Texture map serves as look-up table for our shading equation

( , ) color to shade given point

[ , ] [ , ]

I s t

s t

Texture Shading: Phong Model

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

Texture Shading: Skin

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

Texture Shading: Gooch et al

Shade model with a linear blend of “warm” and “cool” colors

  • cool/warm are blue/yellow

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

Trompe L’oeil

The Triumph of St. Ignatius

Environment Mapping

We can also use texturing to simulate reflections

  • imagine enclosing object in a box
  • project the world onto the sides of the box
  • for any point on the object, compute reflection by looking up

appropriate reflected direction in the cube map

Fairly easy to generate

  • place camera at center of object
  • render scene for each side of the box

But not totally accurate

  • reflections are only accurate for point at

which the images were taken

  • all other reflections are incorrect
  • but people generally never notice

Projection of Reflection Vectors

Environment mapping maps reflection vectors to texture

Need a projection function for reflection vector

reflection vector r

viewing direction u

r !( s , t )

Spherical Projection of Reflection Vectors

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

A

n

ll in eye space!

n

u

r

Reflection vector:

r = u! 2 ( n " u ) n

Environment Mapping with OpenGL

OpenGL uses spherical projection

  • sphere map is view dependent
  • must regenerate when camera moves
    • or else see the same thing

To use environment maps

  • first create the map image
  • then enable texture coordinate generation

glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T);

  • and instruct OpenGL to generate texture coordinates

glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);

glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);

Sphere Maps and Cube Maps

There is a natural mapping between these two

unit sphere unit cube

Sphere Maps for Texture Shading