2IV60 Computer Graphics set 10: Texture mapping Jack van Wijk TU/e.

Slides:



Advertisements
Similar presentations
Hofstra University1 Texture Motivation: to model realistic objects need surface detail: wood grain, stone roughness, scratches that affect shininess, grass,
Advertisements

1 Understanding of OpenGL TA: Dong Hyun Jeong Instructor : Dr. Kalpathi Subramanian Texture Mapping.
OpenGL Texture Mapping
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.
ADDITIONAL TIPS Multi-texture Slides. Here is a link Workflow: /**************In texture parameter set up******/ call glActiveTextureARB(/*pick texture.
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.
Texture Mapping A way of adding surface details Two ways can achieve the goal:  Surface detail polygons: create extra polygons to model object details.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
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
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Lecture 8: Texture Mapping 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271
Texture Mapping. Scope Buffers Buffers Various of graphics image Various of graphics image Texture mapping Texture mapping.
Texture Mapping. Introduction What is Texture Mapping? Types of Texture Mapping –1D, 2D and 3D SDL and OpenGL.
Texture Mapping. Example Mappings Mapping Techniques Consider the problem of rendering a sphere in the examples The geometry is very simple - a sphere.
Texturing A picture is worth a thousand words. Texturing Texturing is the art of doing this with any picture to any model.  (This is Opus the Penguin.
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
ECSE-4750 Computer Graphics Fall 2004 Prof. Michael Wozny TA. Abhishek Gattani TA. Stephen
CS380 LAB IV OpenGL Jonghyeob Lee Reference1. [OpenGL course slides by Rasmus Stenholt] Reference2. [
Texture Mapping Fall, Textures Describe color variation in interior of 3D polygon  When scan converting a polygon, vary pixel colors according.
Lecture 27: Texture Mapping Li Zhang Spring 2008
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.
TEXTURES & OTHER GOODIES Computer Graphics. glTexCoord2f(...); + =
Computer Science Term 1, 2006 Tutorial 2 Assignment 3 – The Virtual World.
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.
October 9, 2002Serguei A. Mokhov, 1 COMP471 – Computer Graphics OpenGL: Texture Mapping.
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.
TEXTURE CSE 410. Add Texture to Polygon glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,texid); // here texid corresponds a bitmap image. glNormal3f(1.0,0.0,0.0);
OpenGL Programming Guide : Texture Mapping Yoo jin wook Korea Univ. Computer Graphics Lab.
1 Graphics CSCI 343, Fall 2015 Lecture 25 Texture Mapping.
Details of Texture Mapping Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, December 1, 2003.
第三课. Overview of this Section Concept of Texture Mapping ( 纹理映射 ) 2D Texture 3D Texture Environment Mapping Bump Mapping Others OpenGL Implementation.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Textures I Week 9, Fri.
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.
Recap Last lecture we looked at local shading models –Diffuse and Phong specular terms –Flat and smooth shading Some things were glossed over –Light source.
Texture Mapping Fall, 2016.
Texture Mapping 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
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.
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.
Assignment 3b Q&A.
Introduction to Texture Mapping
Lecture 21: Texture mapping Li Zhang Spring 2010
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:

2IV60 Computer Graphics set 10: Texture mapping Jack van Wijk TU/e

Texture mapping Need more detail? Paste a picture! Texture: 1-D, 2-D and 3-D image Texture coordinates: Per vertex 1, 2 or 3 extra coordinates that point in the texture H&B 18:

1D Texture mapping 1 1D texture mapping: Color scale for visualization H&B 18-2:

1D Texture mapping 2 Interpolation of colors gives poor results… (255,0,0) (0,255,0) (0,0,255) (0,128,128) (128,128,0) (128,0,128) (85,85,85) H&B 18-2:

1D Texture mapping 3 Coloring with 1D texture-map: better result s=0.5 s=1 s=0 s=0.5 s=0 s=1 s=0.75 s=0.25 H&B 18-2:

2D Texture mapping H&B 10-17: texture space object space image space (u,v)(u,v) (x,y)(x,y) u v x y (s,t)(s,t) s t (s(u),t(v))

Forward mapping Forward mapping: project texture to pixel H&B 10-17: texture space object space image space (u,v)(u,v) (x,y)(x,y) u v x y (s,t)(s,t) s t (s(u),t(v))

Backward mapping Backward mapping: lookup texture per pixel H&B 10-17: texture space object space image space (u,v)(u,v) (x,y)(x,y) u v x y (s,t)(s,t) s t (s(u),t(v))

(s 0, t 0 ) (s 1, t 1 ) (s 2, t 2 ) 2D Texture mapping triangles H&B 10-17: texture space image space (s,t)(s,t) x y (s,t)(s,t) s t (s 0, t 0 ) (s 1, t 1 ) (s 2, t 2 ) Per vertex: specify position (x, y, z) and texture coordinates (s, t) Texture coordinates are interpolated during scan conversion and used to look-up the color. (s,t)(s,t) color(s,t)

3D Texture mapping 3D texture mapping: Texture map is volume (stack of bitmaps): memory intensive Per vertex (s,t,r) coordinates Applications: –medical 3D images (plane through scan) –solid materials (wood) H&B 10-17:

Procedural texturing Instead of using a 1-, 2-, or 3-D image: Define function that returns color dependent on value of s, (s,t) or (s,t,r) Simple: chessboard Advanced: wood, marble, etc. H&B 10-17:

Perlin Procedural texturing Images Ken Buckner. H&B 10-17:

OpenGL 1D Texture Mapping 1 First, make sure texture mapping is enabled: glEnable(GL_TEXTURE_1D); Load the 1D texture map: GlTexImage1D(GL_TEXTURE_1D, // here comes a 1D map 0, // 0: not part of larger array GL_RGBA, // we use RGBA colors nTexColors, // the number of colors (use power of 2) 0, // no border GL_RGBA, // order of bytes in color GL_UNSIGNED_BYTE, // components color: unsigned bytes lineTexArray); // array with color values H&B 18-5:

OpenGL 1D Texture Mapping 2 Use the 1D color map during rendering: glBegin(…); glTexCoord1f(0.2); // one coordinate per vertex glVertex3fv(p1); glTexCoord1f(0.8); glVertex3fv(p2); … glEnd(); H&B 18-5:

OpenGL 2D Texture Mapping 1 First, make sure texture mapping is enabled: glEnable(GL_TEXTURE_1D); Load the 2D texture map: GlTexImage2D(GL_TEXTURE_2D, // here comes a 2D map 0, // 0: not part of larger array GL_RGBA, // we use RGBA colors texwidth, // width of texture map (use power of 2) texHeight, // heigth of map (use power of 2) 0, // no border GL_RGBA, // order of bytes in color GL_UNSIGNED_BYTE, // components color: unsigned bytes surfTexArray); // array with color values H&B 18-5:

OpenGL 2D Texture Mapping 2 Use the 2D color map during rendering: glBegin(…); glTexCoord1f(0.2, 0.8); // two coordinates per vertex glVertex3fv(p1); glTexCoord1f(0.8, 0.8); glVertex3fv(p2); … glEnd(); H&B 18-5:

OpenGL texture parameters 1 Generic call: glTexparameter*(target, parameter, value(s)); * = iv or fv target = GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D Some useful parameters: GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T GL_TEXTURE_MIN_FILTER GL_TEXTURE_MAG_FILTER H&B 18-5:

OpenGL texture parameters 2 glTexparameteri(GL_TEXTURE_2D, GL_WRAP_S, V); glTexparameteri(GL_TEXTURE_2D, GL_WRAP_T, V); H&B 18-5: V = GL_REPEAT: Use only fractional part of texture coordinate V = GL_CLAMP: Clamp texture coordinate to [0, 1] range texture map (0,0)(1,0) (1,1)(0,1) (-1,2)(2,3) (2,-1)(-1,-1) All coordinates: (s,t) texture coordinates Quadrilateral

OpenGL texture parameters 3 glTexparameteri(GL_TEXTURE_2D, GL_WRAP_S, V); glTexparameteri(GL_TEXTURE_2D, GL_WRAP_T, V); H&B 18-5: V = GL_REPEAT: Use only fractional part of texture coordinate V = GL_CLAMP: Clamp texture coordinate to [0, 1] range (-1,2)(2,3) (2,-1)(-1,-1) GL_REPEAT, GL_REPEAT GL_REPEAT, GL_CLAMP GL_CLAMP, GL_CLAMP

OpenGL texture parameters 4 glTexparameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, V); glTexparameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, V); H&B 18-5: Texture Pixel V = GL_NEAREST Texture Pixel V = GL_LINEAR Can be set independently for enlarged textures ( MAG_FILTER ) and shrunk textures ( MIN_FILTER ).

OpenGL texture color glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, V) V = GL_MODULATE Final color is product of current color and texture color Default value. Using texture on black object has no effect! V = GL_REPLACE Final color is texture color Simplest to use. V = GL_DECAL, GL_BLEND If you want to do something special. H&B 18-5:

OpenGL named textures 1 Multiple textures simultaneously in one scene? Using glTexImage2D multiple times per frame is expensive. Solution: named textures. Initially bind textures to symbolic id’s: myTextureInit(); // Taken care of in template assignment { glBindTexture(GL_TEXTURE_2D, head_texture_id); glTexImage2D(..., head_texture); glBindTexture(GL_TEXTURE_2D, torso_texture_id); glTexImage2D(..., torso_texture); glBindTexture(GL_TEXTURE_2D, bricks_texture_id); glTexImage2D(..., bricks_texture); } H&B 18-5:

OpenGL named textures 2 Multiple textures simultaneously in one scene? Using glTexImage2D multiple times per frame is expensive. Solution: named textures. During drawing: refer to symbolic id’s: myDraw(); { glBindTexture(GL_TEXTURE_2D, head_texture_id); myDrawHead(); glBindTexture(GL_TEXTURE_2D, torso_texture_id); myDrawTorso(); glBindTexture(GL_TEXTURE_2D, bricks_texture_id); myDrawBricks(); } H&B 18-5:

Texture mapping hints Use texture maps with dimensions that are a power of 2 (128  128, 128  256, 512  512, etc.); Try to minimize distortion, i.e., aim at using dimensions in texture space that are proportional to dimensions in world space; Use: glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); You can use multiple pictures in one texture map, and control via texture coordinates which picture you use. H&B 18-5:

Finally How about hidden surfaces?