Texture Mapping + Texture Object = Texture Mapped Object.

Slides:



Advertisements
Similar presentations
Graphics Pipeline.
Advertisements

Texture Mapping. Texturing  process that modifies the appearance of each point on a surface using an image or function  any aspect of appearance can.
TEXTURE MAPPING JEFF CHASTINE 1. TEXTURE MAPPING Applying an image (or a texture ) to geometry 2D images (rectangular) 3D images (volumetric – such as.
OpenGL Texture Mapping
Texture Mapping. Typical application: mapping images on geometry 3D geometry (quads mesh) + RGB texture 2D (color-map) =
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Textures II Week 8, Wed.
Texture Mapping CPSC /24/03 Abhijeet Ghosh.
CSC345: Advanced Graphics & Virtual Environments
OpenGL Texture Mapping
OpenGL Texture Mapping Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
OpenGL Texture Mapping April 16, Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Basic Stragegy Three steps to applying a texture.
CS 4731: Computer Graphics Lecture 17: Texturing Emmanuel Agu.
OpenGL Pixel Operations, Bitmaps, Fonts and Images The Current Raster Position Current raster position: A position in window coordinates where the next.
Texture Mapping A way of adding surface details Two ways can achieve the goal:  Surface detail polygons: create extra polygons to model object details.
Texture Mapping. To add surface details… World of Warcraft, Blizzard Inc. More polygons (slow and hard to handle small details) Less polygons but with.
Computer Graphics Texture Mapping Eriq Muhammad Adams
Introduction to Texture Mapping CSE 470/598 Introduction to Computer Graphics Arizona State University Dianne Hansford.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
11/11/04© University of Wisconsin, CS559 Fall 2004 Last Time Shading Interpolation Texture mapping –Barycentric coordinates for triangles.
2002 by Jim X. Chen: 1 Texture Lab At each rendered pixel, selected texels are used either to substitute for or to scale.
1 SIC / CoC / Georgia Tech MAGIC Lab Rossignac Textures and shadows  Generation  Mipmap  Texture coordinates,
Texture Mapping. Scope Buffers Buffers Various of graphics image Various of graphics image Texture mapping Texture mapping.
Texture Mapping. Example Mappings Mapping Techniques Consider the problem of rendering a sphere in the examples The geometry is very simple - a sphere.
Texture Mapping CSE167: Computer Graphics Instructor: Steve Rotenberg
Computer Graphics OpenGL - Texture mapping. OpenGL Texture mapping zTexture Mapping allows us to glue an image on polygons. In this method we can produce.
Texture Mapping Course: Computer Graphics Presented by Fan Chen
Computer Graphics Ben-Gurion University of the Negev Fall 2012.
Mapping method Texture Mapping Environmental mapping (sphere mapping) (cube mapping)
An Interactive Introduction to OpenGL Programming Ed Angel
ECSE-4750 Computer Graphics Fall 2004 Prof. Michael Wozny TA. Abhishek Gattani TA. Stephen
Imaging and Raster Primitives Vicki Shreiner. 2 Jobs Andrew Giles Andrew Giles Chuck Fultz Chuck Fultz SIGGraph - SIGGraph.
Texture Mapping Fall, Textures Describe color variation in interior of 3D polygon  When scan converting a polygon, vary pixel colors according.
And Some Extra Information From
Texture Mapping. 2 Motivation A typical modern graphics card can handle 10s of millions of polygons a second. How many individual blades of grass are.
OpenGL Texture Mapping. 2 Objectives Introduce the OpenGL texture functions and options.
Texture Mapping Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
CS 480/680 Computer Graphics OpenGL Texture Mapping Dr. Frederick C Harris, Jr. Fall 2011.
Texture Mapping Software College, Shandong University Instructor: Zhou Yuanfeng
Texture Mapping in OpenGL. Texture Mapping Imaging we are “pasting” a picture onto a model  Which part of the picture will be pasted onto which part.
Texture Mapping Drawing Pictures on Polygons. Texture Mapping.
CHAPTER 8 Color and Texture Mapping © 2008 Cengage Learning EMEA.
111/17/ :24 UML Solution Involves Selection of Discrete Representation Values.
2 COEN Computer Graphics I Evening’s Goals n Discuss displaying and reading image primitives n Describe texture mapping n Discuss OpenGL modes and.
Texture Mapping. 2 3 Loading Textures void glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border,
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
OpenGL Programming Guide : Texture Mapping Yoo jin wook Korea Univ. Computer Graphics Lab.
Computer Graphics Bing-Yu Chen National Taiwan University.
1 Graphics CSCI 343, Fall 2015 Lecture 25 Texture Mapping.
第三课. Overview of this Section Concept of Texture Mapping ( 纹理映射 ) 2D Texture 3D Texture Environment Mapping Bump Mapping Others OpenGL Implementation.
1 Chapter 7 Texture Mapping. 2 The Limits of Geometric Modeling Although graphics cards can render over 10 million polygons per second, that number is.
CS425 © 2003 Ray S. Babcock Pixels and Bitmaps ● OpenGL allows us to work directly with bits and groups of bits, or pixels, which flow down a parallel.
Texture Mapping CEng 477 Introduction to Computer Graphics.
Texture Mapping Fall, 2016.
Texture Mapping 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
OpenGL Texture Mapping
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
OpenGL Texture Mapping
Introduction to Computer Graphics with WebGL
Computer Graphics, Lee Byung-Gook, Dongseo Univ.
Chapters VIII Image Texturing
Introduction to Texture Mapping
Geb Thomas Adapted from the OpenGL Programming Guide
Class 26 more textures environmental textures Color ramps
3D Game Programming Texture Mapping
OpenGL Texture Mapping
Class 27 more textures environmental textures Color ramps
OpenGL Texture Mapping
Programming Textures Lecture 15 Fri, Sep 28, 2007.
3D Game Programming Texture Mapping
OpenGL Texture Mapping
Presentation transcript:

Texture Mapping + Texture Object = Texture Mapped Object

Texture Mapping Basics Basic Concepts Texture (2D Texture): A two-dimensional array of data Texel : An individual data element in a texture Texture Space : A normalized coordinate space in which the texture is specified. t 1 (s, t): Texture Coordinates 0.0  s  1.0, 0.0  t  1.0 s 1

Surface-Texture Transformation Transform from object space (x, y, z) to texture space (s, t) Curved surface Parametric equation P = P(u, v). Usually transform from parametric space (u, v) to texture space (s, t) Example: Sphere Parametric equation: z P = (x, y, z) r  y  Surface-Texture Transformation x

Polygon surface Specify texture coordinates for each vertex. Then linearly interpolate texture coordinates across projected polygon. y 3 1 Scan line y 4 p(x, y) 5 2 x

Texture Mapping Procedure Projected Pixel Area yd t Pixel Area Object Surface s Pixel Center xd Device Space Object Space Texture Space Surface-texture transformation

Polygon surface with texture coordinates for four corners Texture Wrapping Methods Methods to deal with texture coordinates outside [0, 1] range. (0, 3) (3, 3) Texture (0, 0) (3, 0) Polygon surface with texture coordinates for four corners

Repeat Mirrored Repeat n  s < n  1 s  s  n n  s < n  1 if (n is even number) s  s  n if (n is odd number) s  n  1  s

Clamp Border Clamp if (s < 0) s  0 if (s > 1) s  1 if (s < 0) {s  0; Use border color;} if (s > 1) {s  1; Use border color;} Border Color:

One-Dimensional and Three-Dimensional Texture One-Dimensional Texture (Linear Texture) Three-Dimensional Texture (Volume Texture, Solid Texture) One-dimensional array of data. Three-dimensional array of data. Texture coordinate s. Texture coordinates (s, t, r). r s 1 s t

Texture Mapping Examples

Texture Filtering Nearest Filtering Linear Filtering Texture Filtering: Determine screen pixel color from texel color values using projected pixel area in texture space. Nearest Filtering Linear Filtering Mipmap Nearest Filtering Mipmap Linear Filtering Anisotropic Filtering

Texture Minification and Magnification Projected Pixel Area Projected Pixel Area s s Minification: Projected pixel area in texture space is larger than a single texel. Magnification: Projected pixel area in texture space is smaller than a single texel.

Projected Pixel Center Nearest Filtering (Point Sampling) Select the texel whose center lies nearest to the projected pixel center. Use the color of this texel as pixel color. t Projected Pixel Center Nearest Texel Center s Nearest filtering can result in severe aliasing effects and blocky images.

Projected Pixel Center Linear Filtering (Bilinear Filtering) Select 22 array of texels that lie nearest to the projected pixel center. The pixel color is linearly interpolated from these texels. t Projected Pixel Center s Linear filtering produces better and smooth texture mapped images.

Texture array mn (s0, t0+t) (s0+s, t0+t) (s, t) (s0, t0)

Mipmap Using a single texture, when object surface moves further away from the viewer, texture mapping may result in artifacts such as shimmering and flashing. Mipmap (multum in parvo, many things in a small place): A series of prefiltered texture images with decreasing resolution. Level 0 (8  8) Level 1 (4  4) Level 2 (2  2) Level 3 (1  1) Mipmap is only used for texture minification. Higher mipmap level should be chosen for longer distance between object surface and the viewer.

Mipmap Nearest Filtering Choose the nearest mipmap level. Mipmap Linear Filtering Choose the two nearest mipmap levels. Linearly interpolate between texels sampled from these two levels. Trilinear Filtering: Use mipmap linear filtering for sampling between mipmap levels and use bilinear filtering for sampling within each mipmap level.

Without Mipmap With Mipmap

Anisotropic Filtering Texture anisotropy: The projected pixel area in texture space has elongated shape if the object surface forms a steep angle with respect to view plane. yd Projected Pixel Area t Pixel Area Object Surface s xd View Plane

yd Object Surface Projected Pixel Area t Pixel Area s xd View Plane Anisotropic Filtering: Use multiple samples in projected pixel area. Different sample patterns are used for different projected pixel area shape.

Trilinear Filtering Anisotropic

OpenGL Texture Mapping OpenGL Texture Mapping Procedures: Create Texture Object. Specify Texture Image for Texture Object. Specify Texture Parameters (Texture Wrapping and Filtering Modes) for Texture Object. Specify Texture Environment (The way in which texel color is combined with fragment color). Enable Texture Mapping and Bind Texture Object. Render Primitives. Specify Texture Coordinates for Each Vertex.

Texture Objects A texture object stores texture image data and texture parameters. Each texture object is identified by a positive integer index number. Procedures to use texture objects: Generate texture object names. Initially bind texture objects and set texture image data and parameters. Bind and rebind texture objects for rendering. Delete texture objects when they are no longer needed.

Generate Texture Object Names void glGenTextures(GLsizei n, GLuint *textureNames) Return n currently unused integer index names for texture objects and store them in array textureNames. GLboolean glIsTexture(GLuint textureName) Return GL_TRUE if textureName is currently used as the name for a texture object. Otherwise return GL_FALSE. Delete Texture Objects void glDeleteTextures(GLsizei n, const GLuint *textureNames) Delete n texture objects whose names are stored in array textureNames. Their data is released and their names are freed.

Bind Texture Objects void glBindTexture(GLenum target, GLuint textureName) When using textureName for the first time, a new texture object is created. When binding to a previously created texture object, that texture object becomes active. target: Texture target textureName: Texture object name target Meaning GL_TEXTURE_1D One-dimensional Texture GL_TEXTURE_2D Two-dimensional Texture GL_TEXTURE_3D Three-dimensional Texture GL_TEXTURE_CUBE_MAP Cube Environment Map Use glEnable(target) to enable texture mapping. Use glDisable(target) to disable texture mapping.

Specify Texture Image Texture image can be specified from system memory or frame buffer. Texture image of a texture object can be replaced entirely or partly after it is initially specified. Texture image can be 1D, 2D or 3D. 3D texture support was added in OpenGL 1.2. Cube environment map texture consists of six 2D square texture images. Cube map support was added in OpenGL 1.3.

Specify or Replace Texture Image from System Memory glTexImage*(), glTexSubImage*() System Memory Texture Memory Frame Buffer Unpack Pack Fragment Operations Pixel Storage Modes Pixel Transfer Operations (Pixel Map) Rasterization (Pixel Zoom)

Specify or Replace Texture Image from Frame Buffer glCopyTexImage*(), glCopyTexSubImage*() System Memory Texture Memory Frame Buffer Unpack Pack Fragment Operations Pixel Storage Modes Pixel Transfer Operations (Pixel Map) Rasterization (Pixel Zoom)

Two-Dimensional Texture void glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *texels) Specify a 2D texture image from system memory. The image is set for texture object currently bound to target. target: 2D texture image target. level: Mipmap level. Base level is 0. internalFormat: Internal format for texel data. Indicates how texture image is stored internally in texture memory. width: Width of the texture image. height: Height of the texture image. border: Width of the texture image border. Must be 0 or 1. format: Texel data format of source image. type: Texel data type of source image. texels: System memory that stores source image data.

width and height must be (2n + 2border), where n is an integer. format and type have the same meaning as in glReadPixels() and glDrawPixels(), except that format can not be GL_STENCIL_INDEX. 2D Texture Image Target target Meaning GL_TEXTURE_2D 2D texture image GL_TEXTURE_CUBE_MAP_POSITIVE_X Cube map +x face GL_TEXTURE_CUBE_MAP_NEGATIVE_X Cube map x face GL_TEXTURE_CUBE_MAP_POSITIVE_Y Cube map +y face GL_TEXTURE_CUBE_MAP_NEGATIVE_Y Cube map y face GL_TEXTURE_CUBE_MAP_POSITIVE_Z Cube map +z face GL_TEXTURE_CUBE_MAP_NEGATIVE_Z Cube map z face

Internal Format Base Internal Format Texel data components GL_RGB (R, G, B, 1) GL_RGBA (R, G, B, A) GL_ALPHA (0, 0, 0, A) GL_LUMINANCE (L, L, L, 1) GL_LUMINANCE_ALPHA (L, L, L, A) GL_INTENSITY (I, I, I, I) GL_DEPTH_COMPONENT Depth Value R = Red, G = Green, B = Blue, A = Alpha L = Luminance, I = Intensity

Base Internal Format Internal Format GL_RGB GL_RGB, GL_R3_G3_B2, GL_RGB4, GL_RGB5, GL_RGB8, GL_RGB10, GL_RGB12, GL_RGB16 GL_RGBA GL_RGBA, GL_RGBA2, GL_RGBA4, GL_RGB5_A1, GL_RGBA8, GL_RGB10_A2, GL_RGBA12, GL_RGBA16 GL_ALPHA GL_ALPHA, GL_ALPHA4, GL_ALPHA8, GL_ALPHA12, GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE, GL_LUMINANCE4, GL_LUMINANCE8, GL_LUMINANCE12, GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE_ALPHA, GL_LUMINANCE4_ALPHA4, GL_LUMINANCE6_ALPHA2, GL_LUMINANCE8_ALPHA8, GL_LUMINANCE12_ALPHA4, GL_LUMINANCE12_ALPHA12, GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY, GL_INTENSITY4, GL_INTENSITY8, GL_INTENSITY12, GL_INTENSITY16 GL_DEPTH_COMPONENT GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT32

Use glGetIntegerv(GL_MAX_TEXTURE_SIZE, …) to obtain maximum supported texture size without border. Use glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, …) to obtain maximum supported cube map texture size without border. To use an image with width or height that is not power of two (without border) as texture image, it must be scaled first. int gluScaleImage(GLenum format, GLint widthin, GLint heightin, GLenum typein, const void *datain, GLint widthout, GLint heightout, GLenum typeout, const void *dataout) Scale an image. Return 0 if succeeds, otherwise return a GLU error code. format: Pixel data format widthin, heightin: Width and height of input image typein: Pixel data type of input image datain: Input image data widthout, heightout: Width and height of output image typeout: Pixel data type of output image dataout: Output image data

void glCopyTexImage2D(GLenum target, GLint level, void glCopyTexImage2D(GLenum target, GLint level, GLint internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) Specify a 2D texture image from frame buffer. target: 2D texture image target. level: Mipmap level. Base level is 0. internalFormat: Internal format for texel data. x, y: Lower left corner of the source image in frame buffer. width: Width of the texture image. height: Height of the texture image. border: Width of the texture image border. Must be 0 or 1. target, level, internalFormat, width, height and border have the same meaning as in glTexImage2D().

void glTexSubImage2D(GLenum target, GLint level, GLint xoff, GLint yoff, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *texels) Replace a subimage of a 2D texture with image data from system memory. xoff, yoff: Texel offsets of the lower left corner of the subimage with respect to the lower left corner of the entire texture image. width: Width of the texture subimage. height: Height of the texture subimage. Other parameters have the same meaning as in glTexImage2D(). void glCopyTexSubImage2D(GLenum target, GLint level, GLint xoff, GLint yoff, GLint x, GLint y, GLsizei width, GLsizei height) Replace a subimage of a 2D texture with image data from frame buffer. x, y: Lower left corner of the source image rectangle in frame buffer. Other parameters have the same meaning as in glTexSubImage2D().

width Sub-Image height xoff yoff Texture Image

Automatic Mipmap Generation int gluBuild2DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *texels) Construct a series of mipmaps down to resolution of 1  1, then call glTexImage2D() to load texture images on all mipmap levels. Also automatically scale the original image so that its width and height become power of two. All parameters have the same meaning as in glTexImage2D(). Return 0 if succeeds, otherwise return a GLU error code.

One-Dimensional Texture glTexImage1D(), glTexSubImage1D() glCopyTexImage1D(), glCopyTexSubImage1D() gluBuild1DMipmaps() Three-Dimensional Texture glTexImage3D(), glTexSubImage3D() glCopyTexImage3D(), glCopyTexSubImage3D() gluBuild3DMipmaps()

Specify Texture Parameters void glTexParameteri(GLenum target, GLenum pname, GLint param) void glTexParameterf(GLenum target, GLenum pname, GLfloat param) void glTexParameteriv(GLenum target, GLenum pname, GLint *param) void glTexParameterfv(GLenum target, GLenum pname, GLfloat *param) Specify texture parameters for texture object that is currently bound to target. target: GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D GL_TEXTURE_CUBE_MAP pname: Texture parameter name param: Texture parameter value

Texture parameter name Values GL_TEXTURE_BORDER_COLOR (R, G, B, A) GL_TEXTURE_MAG_FILTER GL_NEAREST GL_LINEAR GL_TEXTURE_MIN_FILTER GL_NEAREST_MIPMAP_NEAREST GL_NEAREST_MIPMAP_LINEAR GL_LINEAR_MIPMAP_NEAREST GL_LINEAR_MIPMAP_LINEAR GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T GL_TEXTURE_WRAP_R GL_REPEAT GL_MIRRORED_REPEAT GL_CLAMP GL_CLAMP_TO_EDGE GL_CLAMP_TO_EDGE was added in OpenGL 1.2. GL_MIRRORED_REPEAT was added in OpenGL 1.4.

Constant Texture Border Color pname = GL_TEXTURE_BORDER_COLOR Constant texture border color is used as border color when the texture image does not have borders. Texture Magnification Filter pname = GL_TEXTURE_MAG_FILTER param Meaning GL_NEAREST Nearest filtering GL_LINEAR Linear filtering

Texture Minification Filter pname = GL_TEXTURE_MIN_FILTER param Meaning GL_NEAREST Nearest filtering (Mipmap is not used) GL_LINEAR Linear filtering (Mipmap is not used) GL_NEAREST_MIPMAP_NEAREST Nearest filtering within each mipmap Nearest filtering between mipmaps GL_NEAREST_MIPMAP_LINEAR Linear filtering between mipmaps GL_LINEAR_MIPMAP_NEAREST Linear filtering within each mipmap GL_LINEAR_MIPMAP_LINEAR

Texture Wrapping Modes pname Meaning GL_TEXTURE_WRAP_S Texture wrapping mode for s coordinate GL_TEXTURE_WRAP_T Texture wrapping mode for t coordinate GL_TEXTURE_WRAP_R Texture wrapping mode for r coordinate param Meaning GL_REPEAT Integer part of texture coordinate is ignored. Border color is always ignored. For linear filtering, 22 texel array wraps to the opposite edge of the texture. GL_MIRRORED_REPEAT Fractional part is reversed at every integer boundary. The rest is the same as GL_REPEAT. GL_CLAMP Texture coordinate is clamped to [0, 1]. Edge color is used for nearest filtering. Border color is used in 22 texel array for linear filtering. GL_CLAMP_TO_EDGE Border color is always ignored. Texels at or near the edge are used.

Specify Texture Environment void glTexEnvi(GLenum envtarget, GLenum pname, GLint param) void glTexEnvf(GLenum envtarget, GLenum pname, GLfloat param) void glTexEnviv(GLenum envtarget, GLenum pname, GLint *param) void glTexEnvfv(GLenum envtarget, GLenum pname, GLfloat *param) Specify texture environment. Texture environment determines how texture color is combined with incoming fragment color. envtarget: Must be GL_TEXTURE_ENV pname param GL_TEXTURE_ENV_MODE GL_REPLACE GL_MODULATE GL_DECAL GL_BLEND GL_TEXTURE_ENV_COLOR Constant environment color (Rc, Gc, Bc, Ac)

Base Internal Format Texture source color (Rs, Gs, Bs, As) GL_RGB (R, G, B, 1) GL_RGBA (R, G, B, A) GL_ALPHA (0, 0, 0, A) GL_LUMINANCE (L, L, L, 1) GL_LUMINANCE_ALPHA (L, L, L, A) GL_INTENSITY (I, I, I, I) Texture source color (Rs, Gs, Bs, As) Incoming fragment color (Rf, Gf, Bf, Af) Constant environment color (Rc, Gc, Bc, Ac) Final combined color (R, G, B, A)

Replace Mode The texture source color components replace corresponding fragment color components. Base Internal Format GL_REPLACE GL_ALPHA R = Rf, G = Gf , B = Bf A = As GL_RGB GL_LUMINANCE R = Rs, G = Gs , B = Bs A = Af GL_RGBA GL_LUMINANCE_ALPHA GL_INTENSITY

Modulation Mode (default mode) The texture source color components multiply corresponding fragment color components. Base Internal Format GL_MODULATE GL_ALPHA R = Rf, G = Gf , B = Bf A = AfAs GL_RGB GL_LUMINANCE R = RfRs, G = GfGs , B = BfBs A = Af GL_RGBA GL_LUMINANCE_ALPHA GL_INTENSITY

Decal Mode For GL_RGB format, The texture source color replace fragment color. For GL_RGBA format, The texture source color is linearly blended with fragment color, using source alpha as blending weight. Base Internal Format GL_DECAL GL_RGB R = Rs, G = Gs , B = Bs A = Af GL_RGBA R = Rf(1  As) + RsAs G = Gf(1  As) + GsAs R = Bf(1  As) + BsAs GL_ALPHA GL_LUMINANCE GL_LUMINANCE_ALPHA GL_INTENSITY undefined

Blending Mode The fragment color is linearly blended with constant environment color, using texture source color as blending weight. Base Internal Format GL_BLEND GL_ALPHA R = Rf, G = Gf , B = Bf A = AfAs GL_RGB GL_LUMINANCE R = Rf(1  Rs) + RcRs G = Gf(1  Gs) + GcGs B = Bf(1  Bs) + BcBs A = Af GL_RGBA GL_LUMINANCE_ALPHA GL_INTENSITY

Specify Texture Coordinates void glTexCoord1{sifd}(TYPE s) void glTexCoord2{sifd}(TYPE s, TYPE t) void glTexCoord3{sifd}(TYPE s, TYPE t , TYPE r) void glTexCoord4{sifd}(TYPE s, TYPE t , TYPE r , TYPE q) void glTexCoord{1234}{sifd}v(TYPE * texcoords) Specify current texture coordinates. Vertices defined using subsequent glVertex*() commands are assigned current texture coordinates. This command must be used between glBegin( ) and glEnd( ). Texture coordinates Meaning Applicable texture target (s) One-dimensional GL_TEXTURE_1D (s, t) Two-dimensional GL_TEXTURE_2D (s, t, r) Three-dimensional GL_TEXTURE_3D GL_TEXTURE_CUBE_MAP (s, t, r, q) Homogeneous

Texture Matrix Texture matrix is a 44 transformation matrix that is used to transform texture coordinates. Texture matrix stack has two entries. Use glMatrixMode(GL_TEXTURE) to set current matrix to texture matrix. All standard matrix manipulation commands can be applied to texture matrix. The default texture matrix is an identity matrix.

Homogeneous Texture Coordinates Homogeneous coordinates (s) (s, 0, 0, 1) (s, t) (s, t, 0, 1) (s, t, r) (s, t, r, 1) (s, t, r, q) [MT] is the texture matrix. (s', t', r') are the transformed texture coordinates. Homogenous texture coordinates also undergo perspective division.

Automatic Texture Coordinate Generation void glTexGen{ifd}(GLenum coord, GLenum pname, TYPE param) void glTexGen{ifd}v(GLenum coord, GLenum pname, TYPE *param) Specify functions for automatic texture coordinate generation. coord: Specify which texture coordinate to use automatic generation. Valid values are GL_S, GL_T, GL_R, GL_Q pname param GL_TEXTURE_GEN_MODE GL_OBJECT_LINEAR GL_EYE_LINEAR GL_SPHERE_MAP GL_REFLECTION_MAP GL_NORMAL_MAP GL_OBJECT_PLANE Plane equation coefficients (A, B, C, D) GL_EYE_PLANE

To enable automatic texture coordinate generation for s-coordinate, use glEnable(GL_TEXTURE_GEN_S). To enable automatic texture coordinate generation for t-coordinate, use glEnable(GL_TEXTURE_GEN_T). To enable automatic texture coordinate generation for r-coordinate, use glEnable(GL_TEXTURE_GEN_R). To enable automatic texture coordinate generation for q-coordinate, use glEnable(GL_TEXTURE_GEN_Q).

Linear Generation Mode (GL_OBJECT_LINEAR, GL_EYE_LINEAR) Texture coordinate = Ax + By + Cz + Dh (A, B, C, D) are plane equation coefficients specified using GL_OBJECT_PLANE parameter. (x, y, z, h) are vertex coordinates in object space. GL_EYE_LINEAR Texture coordinate = A'xe + B'ye + C'ze + D'he [A' B' C' D']=[A B C D][M]1 (A, B, C, D) are plane equation coefficients specified using GL_EYE_PLANE parameter. [M] is modeview matrix when (A, B, C, D) was specified. (xe, ye, ze, he) are vertex coordinates in eye space.

Sphere Map (GL_SPHERE_MAP) Calculate reflection vector R in eye space. Use R to calculate texture coordinates (s, t) for sampling in a sphere environment map. Cube Map (GL_REFLECTION_MAP, GL_NORMAL_MAP) GL_REFLECTION_MAP Calculate reflection vector R in eye space. Use R directly as texture coordinates (s, t, r) for sampling in a cube environment map. GL_NORMAL_MAP Transform normal vector N from object space to eye space. Use transformed N as texture coordinates (s, t, r) for sampling in a cube environment map.