OpenGL Programming Guide : Texture Mapping 2004. 02. 10. Yoo jin wook Korea Univ. Computer Graphics Lab.

Slides:



Advertisements
Similar presentations
Komputer Grafik 2 (AK045206) Pemetaan Tekstur 1/35 Pemetaan Tekstur.
Advertisements

1 Understanding of OpenGL TA: Dong Hyun Jeong Instructor : Dr. Kalpathi Subramanian Texture Mapping.
OpenGL Texture Mapping
CH6 Texture. Before coding … 1/2 Prepare all texture images you need. BMP file is a good choice If you want to use TIFF file, maybe try this.
OpenGL Son of the Survival Guide. Last Time on OpenGL Windowing … glut Rendering Primatives Transformations Projections State Management.
OpenGL Texturing. Content Texture target Texture environment Texture coordinate Texture parameter (filters, wrap) Texture object Texture transformation.
Texture Mapping OpenGl and Implementation Details CS
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.
1 Lecture 12 Texture Mapping uploading of the texture to the video memory the application of the texture onto geometry.
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.
CS 445 / 645 Introduction to Computer Graphics Lecture 17 Texture Maps Lecture 17 Texture Maps.
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
Texture Mapping + Texture Object = Texture Mapped Object.
2IV60 Computer Graphics set 10: Texture mapping Jack van Wijk TU/e.
2002 by Jim X. Chen: 1 Texture Lab At each rendered pixel, selected texels are used either to substitute for or to scale.
Texture Mapping. Introduction What is Texture Mapping? Types of Texture Mapping –1D, 2D and 3D SDL and OpenGL.
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.
An Interactive Introduction to OpenGL Programming Ed Angel
CS 445 / 645 Introduction to Computer Graphics Lecture 19 Texture Maps Lecture 19 Texture Maps.
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.
CS 551 / CS 645 Texture Maps. Assignment 2 Let’s talk about ‘working together’ –No sharing code unless specifically allowed (and documented in README)
OpenGL Texture Mapping. 2 Objectives Introduce the OpenGL texture functions and options.
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.
TEXTURES & OTHER GOODIES Computer Graphics. glTexCoord2f(...); + =
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.
CH8 Frame Buffer Object 1. Introduction Name OpenGL :Frame Buffer Object DirectX:Render Target Usage Render to Texture 2.
Texture Mapping. 2 3 Loading Textures void glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border,
CS 445 / 645 Introduction to Computer Graphics Lecture 19 Texture Maps Lecture 19 Texture Maps.
CH6 Texture. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture blending Per Fragment.
Texture Mapping. checker.c Texture-Mapped Squares.
Computer Graphics Bing-Yu Chen National Taiwan University.
1 Graphics CSCI 343, Fall 2015 Lecture 25 Texture Mapping.
CH6 Texture.
Texture Mapping and NURBS Week 7 David Breen Department of Computer Science Drexel University Based on material from Ed Angel, University of New Mexico.
Details of Texture Mapping Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, December 1, 2003.
CH6 Texture. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture blending Per Fragment.
CH6 Texture. Before coding … 1/2 Prepare all texture images you need. BMP file is a good choice If you want to load other format, you can try the FreeImage.
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
Advanced Graphics Algorithms Ying Zhu Georgia State University
OpenGL Texture Mapping
Computer Graphics, Lee Byung-Gook, Dongseo Univ.
Assignment 3b Q&A.
Geb Thomas Adapted from the OpenGL Programming Guide
3D Game Programming Texture Mapping
Computer Graphics Practical Lesson 6
OpenGL Texture Mapping
OpenGL Texture Mapping
Programming Textures Lecture 15 Fri, Sep 28, 2007.
3D Game Programming Texture Mapping
OpenGL Texture Mapping
Presentation transcript:

OpenGL Programming Guide : Texture Mapping Yoo jin wook Korea Univ. Computer Graphics Lab

Texture Mapping ( 1/3 )  Texture Simply rectangular arrays of data ex) Color data, luminance data, color & alpha data  Texel Individual values in a texture array cf) texel ≠Pixel  requires filtering

Texture Mapping ( 2/3 )

Texture Mapping ( 3/3 )  An Overview & an Example  Specifying the Texture  Filtering  Texture Objects  Texture Functions  Assigning Texture Coordinates  Automatic Texture-Coordinate Generation  Advanced Feature (Multitexturing)

An Overview & an Example ( 1/2 )  Steps in Texture Mapping 1. Create object & Specify a texture 2. Indicate how the texture is to be applied to each pixel 3. Enable Texture mapping 4. Draw the scene

An Overview & an Example ( 2/2 ) Example 9-1

Specifying the Texture ( 1/3 ) target : GL_TEXTURE_2D, GL_PROXY_TEXTURE_2D internalFormat : 1~4 (R,G,B,A) Format : GL_RGB, GL_RGBA, GL_RED …. void glTexImage2D (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *texels)

Specifying the Texture ( 2/3 ) void gluScaleImage (GLenum format, GLint widthin, GLint heightin, GLenum typein, const void *datain, GLint widthout, GLint heightout, GLenum typeout, void *dataout)

Specifying the Texture ( 3/3 ) : Create a two-dimensional texture using framebuffer void glCopyTexImage2D (GLenum target, GLint level, GLint internalFormat, GLint x, GLint y, GLsizei width, Glsizei height GLint border)

Texture Proxy ( 1/3 )  Texture Proxy : answers the question of whether a texture is capable of being loaded into texture memory  Steps in Texture Proxy 1. Create texture proxy with glTexImage2D( ) 2. Query the texture state variables with glGetTexLevelParameter*( )

Texture Proxy ( 2/3 ) pname : GL_TEXTURE_WIDTH, GL_TEXTURE_DEPTH GL_TEXTURE_HEIGHT….. void glGetTexLevelParameter*v(GLenum target, GLint level, GLenum pname, TYPE*params)

Texture Proxy ( 3/3 ) Ex) Glint width; glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGBA8, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);

Replacing a Texture Image ( 1/2 ) xoffset, yoffset : texel offset in the x-,y- direction with (0,0) at the lower left corner of the texture void glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *texels)

Replacing a Texture Image ( 2/2 ) Example 9-3

Multiple Levels of Detail ( 1/4 )  Mipmap : series of prefiltered texture maps of decreasing resolutions ->openGL automatically determines which texture map to use based on the size(in pixels) ->must provide all sizes of your texture in powers of 2 between the largest size and 1×1 map ex) 64×32 : 32×8, 16×4, 8×2, 4×1, 2×1, 1×1

Multiple Levels of Detail ( 2/4 ) Example 9-5

Multiple Levels of Detail ( 3/4 )  Automated Mipmap Generation : define the pyramid of mipmaps down to a resolution 1×1 void gluBuild3DMipmaps(GLenum target, GLint internalFormat, GLint width, GLint height, GLint depth, GLenum format,Glenum type, void *texels)

Multiple Levels of Detail ( 4/4 )  Advanced Mipmap Details parameterDescriptionValues GL_TEXTURE_BASE_LEVE L level for highest-resolution texture in use non-negative integer GL_TEXTURE_MAX_LEVEL level for smallest-resolution texture in use non-negative integer GL_TEXTURE_MIN_LOD ** minimum value for λany value GL_TEXTURE_MAX_LOD ** maximum value for λany value glTexParameter*( ) ** : openGL 1.2

Filtering ( 1/2 )

Filtering ( 2/2 ) parameterValues GL_TEXTURE_MAG_FILTERGL_NEAREST or GL_LINEAR GL_TEXTURE_MIN_FILTERGL_NEAREST, GL_LINEAR GL_NEAREST_MIPMAP_NEAREST GL_NEAREST_MIPMAP_LINEAR GL_LINEAR_MIPMAP_NEAREST GL_LINEAR_MIPMAP_LINEAR glTexParameter*( )

Texture Objects ( 1/4 )  Steps 1. Generate texture names 2. Initially bind texture objects to texture data 3. See if you have enough space for all your texture object 4. Bind and rebind texture objects

Texture Objects ( 2/4 )  Naming A texture Object void glGenTextures (GLsizei n, GLuint *textureNames) Glboolean glIsTexture (GLuint textureName)

Texture Objects ( 3/4 )  Creating and Using Texture Objects void glBindTexture (GLenum target, Gluint textureNames) void glDeleteTexture (GLsizei n, const Gluint *textureNames)

Texture Objects ( 4/4 )  A Working Set of Resident Textures : queries the texture residence status of the n texture object void glAreTexturesResident ( GLsizei n, const Gluint *textureNames, Glboolean *residences)

Texture Functions ( 1/3 ) target : GL_TEXTURE_ENV_MODE, GL_TEXTURE_ENV_COLOR void glTexEnv* (GLenum target, GLenum pname, TYPE param) void glTexEnv*v (GLenum target, GLenum pname, TYPE *param)

Texture Functions ( 2/3 ) pnameparam GL_TEXTURE_ENV_MODE GL_DECAL GL_REPLACE GL_MODULATE GL_BLEND GL_TEXTURE_ENV_COLOR ** Four floating value (R,G,B,A) ** : used only if the GL_BLEND texture function has been specified

Texture Functions ( 3/3 )

Assigning Texture Coordinates ( 1/3 )

Assigning Texture Coordinates ( 2/3 )

Assigning Texture Coordinates ( 3/3 )  Repeat & Clamp glTexImage2D(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT/GL_CLAMP); glTexImage2D(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT/GL_CLAMP);

Automatic Texture-Coordinate Generation ( 1/2 ) coord : GL_S, GL_T, GL_R, GL_Q pname : GL_TEXTURE_GEN_MODE, GL_OBJECT_PLANE, GL_EYE_PLANE param : GL_OBJECT_LINEAR, GL_EYE_LINEAR, GL_SHPERE_MAP or an array of texture generation parameters void glTexGen* (GLenum coord, GLenum pname, TYPE param)

Automatic Texture-Coordinate Generation ( 2/2 )

Multitexturing ( 1/4 )

Multitexturing ( 2/4 )  Steps 1. Check to see if multitexturing is supported - glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, ….) 2. For each texturing unit, establish the texture state - glActiveTextureARB() 3. During vertex specification, use glMultiTexCoord*ARB()

Multitexturing ( 3/4 )  Establishing Texture Unit GLuint texNames[2]; ……………………………. glActiveTextureARB(GL_TEXTURE0_ARB); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texNames[0]); …………………………….. glActiveTextureARB(GL_TEXTURE1_ARB); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texNames[1]); ……………………………..

Multitexturing ( 4/4 )  Specifying glBegin(GL_TRIANGLES); glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 0.0); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, 0.0); glVertex2f(0.0, 0.0); glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.5, 1.0); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.5, 0.0); glVertex2f(50.0, 100.0); glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0, 0.0); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, 1.0); glVertex2f(100.0, 0.0) glEnd();