Download presentation
Presentation is loading. Please wait.
1
Texture Mapping Fall, 2016
2
Textures Describe color variation in interior of 3D polygon
When scan converting a polygon, vary pixel colors according to values fetched from a texture
3
The Quest for Visual Realism
4
Surface Textures Add visual detail to surfaces of 3D objects
5
3D Rendering Pipeline Texture Mapping
6
Texture Mapping Overview
Texture mapping methods Parameterization Mapping Filtering Texture mapping applications Modulation textures Illumination mapping Bump mapping Environment mapping Image-based rendering Non-photorealistic rendering
7
Parameterization Q: How do we describe where on the geometry
each color from the image should go?
8
Option: Varieties of projections
Plane Mapping Cube Mapping Cylinder Mapping Sphere Mapping
9
Parameterization (Example 1)
10
Parameterization (Example 2)
11
Parameterization (Example 3)
12
Parameterization (Example 4)
13
Option: unfold the surface
14
Texture Mapping Overview
Texture mapping methods Parameterization Mapping Filtering Texture mapping applications Modulation textures Illumination mapping Bump mapping Environment mapping Image-based rendering Non-photorealistic rendering
15
Texture Mapping Steps: Define texture
Specify mapping from texture to surface Lookup texture values during scan conversion
16
Texture Mapping When scan convert, map from …
Image coordinate system (x, y) to Modeling coordinate system (u, v) to Texture image (s, t)
17
Texture Mapping Texture mapping is a 2D projective transformation
Texture coordinate system (s, t) to Image coordinate system (x, y)
18
Texture Mapping Scan conversion
Interpolate texture coordinates down/across scan lines Distortion due to bilinear interpolation approximation Cut polygons into smaller ones, or Perspective divide at each pixel
19
Perspective-correct interpolation
Texture Mapping Linear interpolation Perspective-correct interpolation
20
Texture Mapping Overview
Texture mapping methods Parameterization Mapping Filtering Texture mapping applications Modulation textures Illumination mapping Bump mapping Environment mapping Image-based rendering Non-photorealistic rendering
21
Texture Filtering Must sample texture to determine color at each pixel in image
22
Texture Filtering Aliasing is a problem Point Sampling Area Filtering
23
Texture Filtering Ideally, use elliptically shaped convolution filters
24
Texture Filtering Size of filter depends on projection warp
Can prefiltering images Mip maps Summed area tables
25
Mip Maps Keep textures prefiltered at multiple resolutions d v u
For each pixel, linearly interpolate between two closest levels (e. g. trilinear filtering) Fast, easy for hardware u v d
26
Summed-area tables At each texel keep sum of all values down & right
To compute sum of all values within a rectangle, simply subtract two entries Better ability to capture very oblique projections But, cannot store values in a single byte
27
Texture Mapping Overview
Texture mapping methods Parameterization Mapping Filtering Texture mapping applications Modulation textures Illumination mapping Bump mapping Environment mapping Image-based rendering Non-photorealistic rendering
28
Modulation textures Map texture values to scale factor
29
Illumination Mapping +
Map texture values to surface material parameter KA KD KS KT n Key-frame model geometry Decal skin Bump skin Gloss skin WOW! Result +
30
Stores heights: can derive normals
Bump Mapping Texture values perturb surface normals Bump map Stores heights: can derive normals + Bump mapped geometry = geometry
31
Bump Mapping
32
Displacement Mapping Normal Mapping Problem Displacement Mapping
Doesn’t take into account geometric surface depth Does not exhibit parallax No self-shadowing of the surface Coarse silhouettes expose the actual geometry being drawn Displacement Mapping Displace actual positions from Heightfield Map
33
Displacement Mapping
34
Displacement Mapping (Result)
Displacement Offset
35
Environment Mapping Texture values are reflected off surface patch
36
Cube Mapping Cube mapping is the norm nowadays eye x y z n
37
Image-Based Rendering
Map photographics textures to provide details for coarsely detailed polygon model
38
Solid Textures Texture values indexed by 3D location (x, y, z)
Expensive storage, or Compute on the fly ex) Perlin Noise
39
Texture Mapping Summary
Texture mapping methods Parameterization Mapping Filtering Texture mapping applications Modulation textures Illumination mapping Bump mapping Environment mapping Image-based rendering Volume textures
40
Example) Quake 2 Models: Piece by Piece
Model Key Frames Quake 2 interpolates between key frames
41
Example) Quake 2 Models: Piece by Piece
Knight model’s decal skin Texture coordinates map triangles to skin. Note clever packing of decal skin. Only half face because triangles “mirror” the face.
42
Example) Standard Quake 2: Model Rendering
Texture key-frame with decal skin + Key-frame model geometry Decal skin Result
43
Example) GPU Bump-mapped: Quake 2 Model Rendering!
Bump-map model with bump, gloss, & decal skin Bump skin + Key-frame model geometry WOW! Result Gloss skin Decal skin
44
Example) Quake 2 Bump Mapping: Rendering Passes
( ) + ( ) = Diffuse Decal Specular Gloss Final result!
45
Example) More Bump-mapped Knight Examples
Different light positions and key-frames All lighting including specular is computed per-fragment!
46
Example) Bump Mapping Models
Viva la difference
47
OpenGL Texture Mapping
Texture Mapping in OpenGL Allows you to modify the color of a polygon surface Textures are simply rectangular arrays of data (color, luminance, color+alpha). Individual values in a texture are called texels
48
OpenGL Texture Mapping : Step
Steps necessary to use texture mapping: Create a texture object and specify the texture Indicate how the texture is to be applied to each pixel Enable texture mapping Draw the scene, supplying both texture and geometric coordinates
49
OpenGL Texture Mapping : 2D Texture Specification
glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, Glint border, GLenum format, Glenum type, const Glvoid *pixels); target: GL_TEXTURE_2D level: specifies the level of detail when using multi resolution textures. “0” is the base image, “n” is the n-th mipmap reduction image internalFormat: an integer 1 to 4, or one of 38 symbolic constants width, height: the dimensions of the texture (MUST BE power of 2) format: the kind of pixel-data elements type: the data-type of each element pixels: array containing the texture image data Ex) glTexImage2D(GL_TEXTURE_2D, 0, 3, iwidth, iheight, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
50
OpenGL Texture Mapping : Values for Format and Type
Format Constants: GL_COLOR_INDEX: A single color index GL_RGB: A red component, followed by green & blue components GL_RGBA: Like GL_RGB, followed by an alpha component. GL_RED: A single red-color component GL_GREEN: A single green-color component GL_BLUE: A single blue-color component GL_ALPHA: A single alpha-color component Type Constants: GL_UNSIGNED_BYTE: unsigned 8-bit integer GL_BYTE: signed 8-bit integer GL_UNSIGNED_SHORT: unsigned 16-bit integer GL_SHORT: signed 16-bit integer GL_INT: signed 32-bit integer GL_FLOAT: single-precision floating point
51
OpenGL Texture Mapping : Texture Coordinates
You need to specify BOTH texture & geometric coordinates as you specify the object in your scene glColor3f(1.0f, 0.0f, 0.0f); glBegin(GL_TRIANGLES); glNormal3d(0,0,-1); glTexCoord2d(0,0); glVertex3d(-100,-100,0); glTexCoord2d(1,0); glVertex3d(100,-100,0); glTexCoord2d(0,1); glVertex3d(-100,100,0); glEnd();
52
OpenGL Texture Mapping : Texture Filtering
glTexParameteri( target, type, mode) Target : GL_TEXTURE_1D, GL_TEXTURE_2D Type : GL_TEXTURE_MIN_FILTER Mode : GL_NEAREST, GL_LINEAR, GL_NEAREST_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR GL_LINEAR_MIPMAP_LINEAR Type : GL_TEXTURE_MAG_FILTER GL_NEAREST or GL_LINEAR Ex) glTexParameteri(GL_TEXTURE_2D, GL_TEXURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXURE_MIN_FILTER, GL_LINEAR);
53
No mipmapping Mipmappping Min / Max Filter : GL_NEAREST Min / Max Filter : GL_LINEAR
54
OpenGL Texture Mapping : Texture Wrapping
glTexParameteri( target, type, mode) Target : GL_TEXTURE_1D, GL_TEXTURE_2D Type GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T mode GL_CLAMP or GL_REPEAT Wrap S : GL_CLAMP Wrap T : GL_CLAMP Wrap S : GL_CLAMP Wrap T : GL_REPEAT Wrap S : GL_REPEAT Wrap T : GL_CLAMP Wrap S : GL_REPEAT Wrap T : GL_REPEAT
55
OpenGL Texture Mapping : Texturing Functions
Indicate how the texture is applied to each pixel: REPLACE or DECAL: Texture is painted on top of the fragment MODULATE: Combine texture with fragment color. This technique is useful to combine the effects of lighting with texturing BLEND: A constant color is blended with that of the fragment, based on the texture value Ex) glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
56
OpenGL Texture Mapping : Texture Functions
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.