Computer Graphics Texture Mapping Eriq Muhammad Adams

Slides:



Advertisements
Similar presentations
Texture Mapping Graphics scene tanpa texture -> cenderung polosan-> sepi. Untuk membuat permukaan yang kompleks, jika hanya menggunakan bentuk geometri.
Advertisements

Hofstra University1 Texture Motivation: to model realistic objects need surface detail: wood grain, stone roughness, scratches that affect shininess, grass,
Introduction and Basic OpenGL functionality
1 Understanding of OpenGL TA: Dong Hyun Jeong Instructor : Dr. Kalpathi Subramanian Texture Mapping.
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
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.
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.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
2IV60 Computer Graphics set 10: Texture mapping Jack van Wijk TU/e.
Fundamentals of Computer Graphics Part 9 Discrete Techniques prof.ing.Václav Skala, CSc. University of West Bohemia Plzeň, Czech Republic ©2002 Prepared.
2002 by Jim X. Chen: 1 Texture Lab At each rendered pixel, selected texels are used either to substitute for or to scale.
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 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.
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.
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.
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.
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.
第三课. 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.
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.
Chapters VIII Image Texturing
Introduction to Texture Mapping
3D Game Programming Texture Mapping
Computer Graphics Practical Lesson 6
OpenGL Texture Mapping
OpenGL Texture Mapping
Programming Textures Lecture 15 Fri, Sep 28, 2007.
Texture Mapping Ed Angel Professor Emeritus of Computer Science
3D Game Programming Texture Mapping
OpenGL Texture Mapping
Presentation transcript:

Computer Graphics Texture Mapping Eriq Muhammad Adams eriq.adams@ub.ac.id

Texture Mapping A way of adding surface details Two ways can achieve the goal: Surface detail polygons: create extra polygons to model object details Add scene complexity and thus slow down the graphics rendering speed Some fine features are hard to model! Map a texture to the surface (a more popular approach) Complexity of images does Not affect the complexity Of geometry processing (transformation, clipping…)

Texture Representation Bitmap (pixel map) textures (supported by OpenGL) Procedural textures (used in advanced rendering programs) Bitmap texture: A 2D image - represented by 2D array texture[height][width] Each pixel (or called texel ) by a unique pair texture coordinate (s, t) The s and t are usually normalized to a [0,1] range For any given (s,t) in the normalized range, there is a unique image value (i.e., a unique [red, green, blue] set ) s t (0,0) (1,1)

Map textures to surfaces Establish mapping from texture to surfaces (polygons): - Application program needs to specify texture coordinates for each corner of the polygon (0,0) (1,0) (0,1) (1,1) The polygon can be in an arbitrary size

Map textures to surfaces Texture mapping is performed in rasterization (backward mapping) (1,1) (0,1) For each pixel that is to be painted, its texture coordinates (s, t) are determined (interpolated) based on the corners’ texture coordinates (why not just interpolate the color?) The interpolated texture coordinates are then used to perform texture lookup (0,0) (1,0)

Texture Mapping 1. projection 3. patch texel 3D geometry 2. texture lookup 2D projection of 3D geometry S t 2D image

Texture Value Lookup For the given texture coordinates (s,t), we can find a unique image value from the texture map (1,1) How about coordinates that are not exactly at the intersection (pixel) positions? Nearest neighbor Linear Interpolation Other filters (0,0) (0.25,0) (0.5,0) (0.75,0) (1,0)

OpenGL texture mapping Steps in your program 1) Specify texture read or generate image Assign to texture 2) Specify texture mapping parameters Wrapping, filtering, etc. 3) Enable GL texture mapping (GL_TEXTURE_2D) 4) Assign texture coordinates to vertices 5) Draw your objects 6) Disable GL texture mapping (if you don’t need to perform texture mapping any more)

Specify textures Load the texture map from main memory to texture memory glTexImage2D(Glenum target, Glint level, Glint iformat, int width, int height, int border, Glenum format, Glenum type, Glvoid* img) Example: glTeximage2D(GL_TEXTURE_2D, 0, GL_RGB, 64, 64, 0, GL_RGB, GL_UNSIGNED_BYTE, myImage); (myImage is a 2D array: GLuByte myImage[64][64][3]; ) The dimensions of texture images must be powers of 2

Fix texture size If the dimensions of the texture map are not power of 2, you can Pad zeros 2) use gluScaleImage() 60 Ask OpenGL to filter the data for you to the right size – you can specify the output resolution that you want 100 128 Remember to adjust the texture coordinates for your polygon corners – you don’t want to Include black texels in your final picture 64

Texture mapping parameters What happen if the given texture coordinates (s,t) are outside [0,1] range? Example: glTexParameteri(GL_TEXTAURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP) GL_Repeat (0,0) (2,2) (0,0) (2,2) GL_Clamp If (s >1) s = 1 If (t >1) t = 1 (0,0) (1,1) texture

Texture mapping parameters(2) Since a polygon can get transformed to arbitrary screen size, texels in the texture map can get magnified or minified. Filtering: interpolate a texel value from its neighbors or combine multiple texel values into a single one texture texture polygon projection polygon projection Magnification Minification

Texture mapping parameters(3) OpenGL texture filtering: 2) Linear interpolate the neighbors (better quality, slower) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) Nearest Neighbor (lower image quality) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); Or GL_TEXTURE_MAX_FILTER

Texture color blending Determin how to combine the texel color and the object color GL_MODULATE – multiply texture and object color GL_BLEND – linear combination of texture and object color GL_REPLACE – use texture color to replace object color Example: glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

Enable (Disable) Textures Enable texture – glEnable(GL_TEXTURE_2D) Disable texture – glDisable(GL_TEXTURE_2D) Remember to disable texture mapping when you draw non-textured polygons

Specify texture coordinates Give texture coordinates before defining each vertex glBegin(GL_QUADS); glTexCoord2D(0,0); glVertex3f(-0.5, 0, 0.5); … glEnd();

Put it all together … 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_MIN_FILTER, GL_NEAREST); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glEnable(GL_TEXTURE_2D); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 64, 64, 0, GL_RGB, GL_UNSIGNED_BYTE, mytexture); Draw_picture1(); // define texture coordinates and vertices in the function ….

Nate Robin’s Tutorial

Sprite Animation

References Interactive Computer Graphics: A Top-Down Approach with OpenGL by Edward Angel - 5th Edition Computer Graphics Course, Ohio State University, Dept. Comp. Science & Engineering