Download presentation
Presentation is loading. Please wait.
Published byAlyson Walton Modified over 9 years ago
1
CS 551 / CS 645 Texture Maps
2
Assignment 2 Let’s talk about ‘working together’ –No sharing code unless specifically allowed (and documented in README) –Talking about provided start-up code allowed –Talking about generic programming allowed. How does fscanf work? –No helping one another with the graphics-specific programming. Obvious violations in Assignment 2 –Email me today or tomorrow
3
Tuesday Assignment 2 returned Midterm returned Assignment 3 part 2 handed out
4
Review: Area Sampling Shade pixels according to the area covered by thickened line This is unweighted area sampling A rough approximation formulated by dividing each pixel into a finer grid of pixels
5
Review: Weighted Area Sampling Weighting function, W(x,y) –specifies the contribution of primitive passing through the point (x, y) from pixel center x Intensity W(x,y)
6
Review: Point Sampling Multiply sample grid by image intensity to obtain a discrete set of points, or samples. Sampling Geometry
7
Review: Filtering To lower Nyquist rate, remove high frequencies from image: low-pass filter –Only low frequencies remain Sinc function is common filter: –sinc(x) = sin ( x)/ x Spatial Domain Frequency Domain
8
Review: Bilinear Filter Sometimes called a tent filter Easy to compute –just linearly interpolate between samples Finite extent and no negative values Still has artifacts
9
Review: Supersampling Techniques Adaptive supersampling –store more points when necesssary Stochastic supersampling –Place sample points at stochastically determined points Eye has harder time detecting aliasing when combined with the noise generated by stochastics
10
Texture Maps Chapter 9 of Open GL Programming Guide (Red Book) Images applied to polygons to enhance the visual effect of a scene –Rectangular arrays of data Color, luminance, alpha Components of array called texels
11
Texturing in OpenGL Color mode must be RGBA –A stands for Alpha, or opacity Texture applied to pixels of polygon –Replace mode: texture is painted on top of polygon –Modulate polygon color –Blend a constant color with polygon
12
glTexImage2D GLenum target –GL_TEXTURE_2D –GL_PROXY_TEXTURE_2D Provides queries for texture resources Proceed with hypothetical texture use (GL won’t apply the texture) After query, call GLGetTexLevelParamter to verify presence of required system components Doesn’t check possibility of multiple texture interference
13
glTexImage2d GLint level –Used for Level of Detail (LOD) –LOD stores multiple versions of texture that can be used at runtime (set of sizes) –Runtime algorithms select appropriate version of texture Pixel size of polygon used to select best texture Eliminates need for error-prone filtering algorithms
14
glTexImage2D GLint internalFormat –Describes which of R, G, B, and A are used in internal representation of texels –Provides control over things texture can do High bit depth alpha blending High bit depth intensity mapping General purpose RGB –GL doesn’t guarantee all options are available on given hardware
15
glTexImage2D GLsizei width GLsizei height –Dimensions of texture image Must be 2 m + 2b (b=0 or 1 depending on border) min, 64 x 64 GLint border –Width of border (1 or 0) Border allows linear blending between overlapping textures Useful when manually tiling textures
16
glTexImage2D GLenum format –Describe how texture data is stored in input array GL_RGB, GL_RGBA, GL_BLUE… GLenum type –Data size of array components GL_SHORT, GL_BYTE, GL_INT…
17
glTexImage2D Const GLvoid *texels –Pointer to data describing texture map
18
glTexImage2D Be aware of tradeoffs between memory usage, color depth, and speed gluScaleImage will alter the size of an image to meet the 2 m size requirement of OpenGL –Scaling performed by linear and box filtering glCopyTexImage2D –Use current frame buffer contents as texture –Copy frame buffer to named texture location
19
glTexSubImage2D Replace a region of current working texture with a smaller texture SubImage need not adhere to 2 m size limitation This is how you add data from your system’s camera to GL environment glCopyTexSubImage2D –Frame buffer cut and paste possible too
20
Mipmaps A texture LOD technique Prespecify a series of prefiltered texture maps of decreasing resolutions Requires more texture storage Eliminates shimmering and flashing as objects move
21
gluBuild2DMipmaps Automatically constructs a family of textures from original texture size down to 1x1
22
Advanced Mipmaps Runtime mipmap level determination – = max texture size / max polygon size – = log 2 –If texture smaller than polygon and magnification filter is used –If texture is larger than polygon and minification is used (mipmapping) specifies mipmap level
23
Advanced Mipmaps You can specify additional mipmap levels on the fly –MIN_LOD may reduce popping –MAX_LOD may reduce over compression You can specify min mipmap level –Useful for mosaicing
24
Filtering OpenGL tries to pick best mipmap level Question: Which texel corresponds to a particular pixel? GL_NEAREST (Point Sampling) –Pick the texel with center nearest pixel GL_LINEAR (Bilinear Sampling) –Weighted average of 2x2 closest texels GL_LINEAR_MIPMAP_LINEAR –Average texels from two mipmap levels GL_LINEAR_MIPMAP_LINEAR (Trilinear) –Average two averaged texels from two mipmaps
25
Texture Objects glGenTextures –A way to obtain a reference to a texture object glBindTexture –A way to bind a texture to a texture object Desirable to have all the textures stored as memory resident objects Many GL management functions
26
Texture Effects Coloring – like a decal Alpha – average polygon color with texture Lighting – change intensity Specular lighting effects –Lighting mode exists which separates polygon base color from specular color –Texturing can be applied to base color only with specular effects added later
27
Texture Coordinates Every polygon has object coordinates and texture coordinates –Object coordinates describe where polygon vertices are on the screen –Texture coordinates describe texel coordinates of each vertex (usually 0 -> 1) –Texture coordinates are interpolated along vertex-vertex edges glTexCoord{1234}{sifd}(TYPE coords)
28
Texture Coordinates Cones and cylinders easily mapped to rectangular coordinate spaces without distortion Repeating – texture coordinate > 1.0 Clamped – texture coordinate > 1.0 is clamped Think about relationship between filter mode and repeat/clamp
29
Automatic Texture-Coordinate Generation glTexGen –Provides control over how texture is placed on polygon –GL_OBJECT_LINEAR Consistent mapping to object’s coordinate system –GL_EYE_LINEAR Mapping is relative to eyepoint –GL_SPHERE_MAP Environment Mapping
30
Used to model a object that reflects surrounding textures to the eye –Polished sphere reflects walls and ceiling textures –Cyborg in Terminator 2 reflects flaming destruction Texture is distorted fish-eye view of environment Spherical texture mapping creates texture coordinates that correctly index into this texture map
31
The q-coordinate Remember, texture coordinate interpolation is linear Texture coordinates can contain an optional q-parameter Q scales texture coordinates by dividing each coordinate by q This captures perspective transformations
32
Multitexturing Pipelining of multiple texture applications to one polygon The results of each texture unit application is passed to the next texture unit, which adds its effects More bookkeeping is required to pull this off
33
Sony Playstation 2 Seven hours in line at Walmart Total mayhem (two arrested) Fighting over 41 units Debt of Gratitude to: –Vic Ludwig –Brian Salomon –Damian Slonneger
34
Sony Playstation 2
35
Playstation 2 Stats 300 MHz 128 bit RISC “Emotion Engine” chip (from Toshiba) 32 MB Rambus memory Standard DVD-ROM (CD-ROM compatible)
36
Playstation 2 Graphics 150 MHz clock 4 MB video memory 75 Million Polygons Per Second is absolute max 20 Million per second with 48 pixel quads, Z- buffering, alpha blending, and MIP mapping
37
Playstation 2 Graphics MIP-mapping Bi-linear filtering Surface/Edge Anti-aliasing Texture- correction 32 bit Z-buffering
38
Playstation 2 Special Features Plays DVDs right out of the box USB, PCMCIA, and “I-Link” I/O ports for modem and other peripherals Backwards compatibility with Playstation 1 games Hard Drive available in 2001
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.