Download presentation
Presentation is loading. Please wait.
Published byMilo Conley Modified over 6 years ago
1
Texture Mapping We can improve the realism of graphics models by mapping a texture pattern (image) onto the modeled object surface. We refer to this technique as texture mapping or pattern mapping. Adding texture mapping to polygonal models
2
Coordinate Refence Systems
Texture mapping approaches Texture scanning Map the texture pattern to object surface. Map to project to the plane Pixel-order scanning Map pixel areas onto object surfaces. Map to texture space
3
Mapping u = fu(s,t) = aus + but + cu v = fv(s,t) = avs + bvt + cv
4
Example Surface Parameters u = ; 0 < < 90
v = z ; 0 < z < 1 The parametric representation of the surface x = r cos(u) ; y = r sin(u); z = v Map the array to the surface u = s*90 ; v = t Select the viewing position and perform the inverse of the viewing transformation from from pixel coordinate to the cylinder surface.
5
MipMaps Large texture need more memory space and more time to render.
Different resolution texture Close regions have high resolution textures. Far regions have low resolution textures Level-0 Level-1 Level-2
6
Bump Mapping Bump Mapping is used to model the surface roughness.
Bump mapping usually achieved by applying a perturbation function
7
OpenGL Textures Texture width and height are power of 2
Allows border for textures Several image packing strategies Right now, handles 1D and 2D textures Could wrap or clamp textures
8
Code Exampe // During Initialization stage
glBindTexture (GL_TEXTURE_2D, 13); glPixelStorei (GL_UNPACK_ALIGNMENT, 1); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); */ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, img_width, img_height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
9
Code Example //At Display glEnable (GL_TEXTURE_2D);
glBindTexture (GL_TEXTURE_2D, 13); // Start Geometry glTexCoord2f (0.0,0.0); glVertex3f(5.0, 7.1, 3.6);
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.