Madhulika (18010), Assistant Professor, LPU.

Slides:



Advertisements
Similar presentations
Computer Graphics Bing-Yu Chen National Taiwan University.
Advertisements

CSC345: Advanced Graphics & Virtual Environments
Texture Mapping April 9, The Limits of Geometric Modeling Although graphics cards can render over 10 million polygons per second, that number.
OpenGL Texture Mapping
University of New Mexico
OpenGL Texture Mapping Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Texture Mapping Mohan Sridharan Based on slides created by Edward Angel 1 CS4395: Computer Graphics.
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.
Texture Mapping. 2 The Limits of Geometric Modeling Although graphics cards can render over 10 million polygons per second, that number is insufficient.
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.
Fundamentals of Computer Graphics Part 9 Discrete Techniques prof.ing.Václav Skala, CSc. University of West Bohemia Plzeň, Czech Republic ©2002 Prepared.
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 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
COMPUTER GRAPHICS Hochiminh city University of Technology Faculty of Computer Science and Engineering CHAPTER 8: Texture Mapping.
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. 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.
1 Texture Mapping. 2 Texture Aliasing MIPmaps Environment Mapping Bump Mapping Displacement Mapping Shadow Maps Solid Textures Antialiasing.
Texture Mapping Software College, Shandong University Instructor: Zhou Yuanfeng
Texture Mapping Drawing Pictures on Polygons. Texture Mapping.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CG Summary: OpenGL Shading andTextures Angel, Chapters 5, 7; “Red Book” slides from AW, red book, etc. CSCI 6360/4360.
Texture Mapping May 4, Many slides are borrowed from UNC-CH COMP236 Course (Spring 2003) taught by Leonard McMillan
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Texture Mapping and NURBS Week 7 David Breen Department of Computer Science Drexel University Based on material from Ed Angel, University of New Mexico.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
第三课. Overview of this Section Concept of Texture Mapping ( 纹理映射 ) 2D Texture 3D Texture Environment Mapping Bump Mapping Others OpenGL Implementation.
Texture Mapping. For Further Reading Angel 7 th Ed: ­Chapter 7: 7.3 ~ 7.9 Beginning WebGL: ­Chapter 3 2.
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.
Viewing and Texture Mapping In OPENGL. VIEWING 1.One or more objects 2.A viewer with a projection surface 3.Projectors that go from the object(s) to.
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.
University of New Mexico
Buffers and texture mapping
Texture Mapping.
Computer Graphics Texture Mapping
Texture Mapping Fall, 2016.
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
Introduction to Computer Graphics with WebGL
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Advanced Graphics Algorithms Ying Zhu Georgia State University
Advanced Graphics Algorithms Ying Zhu Georgia State University
OpenGL Texture Mapping
Introduction to Computer Graphics with WebGL
Interactive Graphics Algorithms Ying Zhu Georgia State University
Introduction to Computer Graphics with WebGL
Introduction to Texture Mapping
Texture Motivation: to model realistic objects need surface detail: wood grain, stone roughness, scratches that affect shininess, grass, wall paper. Use.
3D Game Programming Texture Mapping
OpenGL Texture Mapping
Texture Mapping Ed Angel Professor Emeritus of Computer Science
OpenGL Texture Mapping
Advanced Computer Graphics: Texture
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:

Madhulika (18010), Assistant Professor, LPU. Computer Graphics Texture Mapping Madhulika (18010), Assistant Professor, LPU.

Madhulika (18010), Assistant Professor, LPU. Objectives Introduce Mapping Methods Texture Mapping Madhulika (18010), Assistant Professor, LPU.

Madhulika (18010), Assistant Professor, LPU. Texture can either be two-dimensional or three-dimensional and is distinguished by visual and physical textures. Physical Texture: Physical texture is known as actual texture or tactile texture. It depicts the variations on a particular surface. Physical texture can be felt by touch. Fur, wood, grains, statues, sand, glass, and so on can be included in this type of texture. 2. Visual Texture: Visual texture is the perception of having a physical texture. Every material has its own visual texture which needs to be considered before creating a composition. Textures are created by repetitive use of shapes and lines. Madhulika (18010), Assistant Professor, LPU.

Madhulika (18010), Assistant Professor, LPU. Texture Mapping: Texture mapping makes use of photographical or procedural generated textures. These procedural generated patterns are made to appear very natural by subjecting them to noise or random variation. The texture mapping method involves scanning or digitizing the picture into another space, 2-D texture space. Madhulika (18010), Assistant Professor, LPU.

The Limits of Geometric Modeling Although graphics cards can render over 10 million polygons per second, that number is insufficient for many phenomena Clouds Grass Terrain Skin Madhulika (18010), Assistant Professor, LPU.

Madhulika (18010), Assistant Professor, LPU. Modeling an Orange Consider the problem of modeling an orange (the fruit) Start with an orange-colored sphere Too simple Replace sphere with a more complex shape Does not capture surface characteristics (small dimples) Takes too many polygons to model all the dimples Madhulika (18010), Assistant Professor, LPU.

Madhulika (18010), Assistant Professor, LPU. Modeling an Orange (2) Take a picture of a real orange, scan it, and “paste” onto simple geometric model This process is known as texture mapping Still might not be sufficient because resulting surface will be smooth Need to change local shape Bump mapping Madhulika (18010), Assistant Professor, LPU.

Madhulika (18010), Assistant Professor, LPU. Three Types of Mapping Texture Mapping Uses images to fill inside of polygons Environment (reflection mapping) Uses a picture of the environment for texture maps Allows simulation of highly specular surfaces Bump mapping Emulates altering normal vectors during the rendering process Madhulika (18010), Assistant Professor, LPU.

Texture Surface Patterns Texture mapping Consists in mapping patterns onto the geometric description of an object. Texture Pattern to be mapped either an array of color values or as a procedure that modifies existing color or as an image from an image file Madhulika (18010), Assistant Professor, LPU.

Madhulika (18010), Assistant Professor, LPU. Texture Mapping geometric model texture mapped Madhulika (18010), Assistant Professor, LPU.

Madhulika (18010), Assistant Professor, LPU. Environment Mapping Madhulika (18010), Assistant Professor, LPU.

Madhulika (18010), Assistant Professor, LPU. Bump Mapping Madhulika (18010), Assistant Professor, LPU.

Where does mapping take place? Mapping techniques are implemented at the end of the rendering pipeline Very efficient because few polygons make it past the clipper Madhulika (18010), Assistant Professor, LPU.

Madhulika (18010), Assistant Professor, LPU. Is it simple? Although the idea is simple---map an image to a surface---there are 3 or 4 coordinate systems involved 2D image 3D surface Madhulika (18010), Assistant Professor, LPU.

Madhulika (18010), Assistant Professor, LPU. Coordinate Systems Parametric coordinates May be used to model curves and surfaces Texture coordinates Used to identify points in the image to be mapped Object or World Coordinates Conceptually, where the mapping takes place Window Coordinates Where the final image is really produced Madhulika (18010), Assistant Professor, LPU.

Madhulika (18010), Assistant Professor, LPU. Texture Mapping parametric coordinates texture coordinates window coordinates world coordinates Madhulika (18010), Assistant Professor, LPU.

Madhulika (18010), Assistant Professor, LPU. Mapping Functions Basic problem is how to find the maps Consider mapping from texture coordinates to a point a surface Appear to need three functions x = x(s,t) y = y(s,t) z = z(s,t) But we really want to go the other way (x,y,z) t s Madhulika (18010), Assistant Professor, LPU.

OpenGL Texture Mapping

Madhulika (18010), Assistant Professor, LPU. Objectives Introduce the OpenGL texture functions and options Madhulika (18010), Assistant Professor, LPU.

Madhulika (18010), Assistant Professor, LPU. Basic Strategy Three steps to applying a texture specify the texture read or generate image assign to texture enable texturing assign texture coordinates to vertices Proper mapping function is left to application specify texture parameters filtering Madhulika (18010), Assistant Professor, LPU.

Madhulika (18010), Assistant Professor, LPU. Texture Mapping x y z geometry display s t image Madhulika (18010), Assistant Professor, LPU.

Madhulika (18010), Assistant Professor, LPU. Texture Example The texture (below) is a 256 x 256 image that has been mapped to a rectangular polygon which is viewed in perspective Madhulika (18010), Assistant Professor, LPU.

Texture Mapping and the OpenGL Pipeline Images and geometry flow through separate pipelines that join during fragment processing “complex” textures do not affect geometric complexity geometry pipeline vertices pixel pipeline image fragmentprocessor Madhulika (18010), Assistant Professor, LPU.

Specifying a Texture Image Define a texture image from an array of texels (texture elements) in CPU memory Glubyte my_texels[512][512]; Define as any other pixel map Scanned image Generate by application code Enable texture mapping glEnable(GL_TEXTURE_2D) OpenGL supports 1-4 dimensional texture maps Madhulika (18010), Assistant Professor, LPU.

Define Image as a Texture glTexImage2D( target, level, components, w, h, border, format, type, texels ); target: type of texture, e.g. GL_TEXTURE_2D level: used for mipmapping components: number of color components w, h: width and height of texels in pixels border: used for smoothing format and type: describe texels texels: pointer to texel array glTexImage2D(GL_TEXTURE_2D, 0, 3, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, my_texels); Madhulika (18010), Assistant Professor, LPU.

Madhulika (18010), Assistant Professor, LPU. Mapping a Texture Based on parametric texture coordinates glTexCoord*() specified at each vertex Texture Space Object Space t 1, 1 (s, t) = (0.2, 0.8) 0, 1 A a c (0.4, 0.2) b B C s (0.8, 0.4) 0, 0 1, 0 Madhulika (18010), Assistant Professor, LPU.

Madhulika (18010), Assistant Professor, LPU. Typical Code glBegin(GL_POLYGON); glColor3f(r0, g0, b0); //if no shading used glNormal3f(u0, v0, w0); // if shading used glTexCoord2f(s0, t0); glVertex3f(x0, y0, z0); glColor3f(r1, g1, b1); glNormal3f(u1, v1, w1); glTexCoord2f(s1, t1); glVertex3f(x1, y1, z1); . glEnd(); Note that we can use vertex arrays to increase efficiency Madhulika (18010), Assistant Professor, LPU.

Madhulika (18010), Assistant Professor, LPU. Interpolation OpenGL uses interpolation to find proper texels from specified texture coordinates Can be distortions texture stretched over trapezoid showing effects of bilinear interpolation good selection of tex coordinates poor selection of tex coordinates Madhulika (18010), Assistant Professor, LPU.

Magnification and Minification More than one texel can cover a pixel (minification) or more than one pixel can cover a texel (magnification) Can use point sampling (nearest texel) or linear filtering ( 2 x 2 filter) to obtain texture values Texture Polygon Magnification Minification Madhulika (18010), Assistant Professor, LPU.

Madhulika (18010), Assistant Professor, LPU. Filter Modes Modes determined by glTexParameteri( target, type, mode ) glTexParameteri(GL_TEXTURE_2D, GL_TEXURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXURE_MIN_FILTER, GL_NEAREST); Note that linear filtering requires a border of an extra texel for filtering at edges (border = 1) Madhulika (18010), Assistant Professor, LPU.

Madhulika (18010), Assistant Professor, LPU. Applying Textures II specify textures in texture objects set texture filter set texture function enable texturing supply texture coordinates for vertex coordinates can also be generated Madhulika (18010), Assistant Professor, LPU.

Madhulika (18010), Assistant Professor, LPU. #include<GL/glut.h> #define red {0xff,0x00,0x00} #define blue {0x00,0x00,0xff} GLubyte texture[][3]={ red,blue, blue,red, }; void reshape(int width, int height){ glViewport(0,0,width,height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(80,GLfloat(width)/height,1,40); glMatrixMode(GL_MODELVIEW); gluLookAt(2,-1,5,0,0,0,0,1,0); glEnable(GL_TEXTURE_2D); glPixelStorei(GL_UNPACK_ALIGNMENT,1); glTexImage2D(GL_TEXTURE_2D, 0, 3, 2,2, 0, GL_RGB, GL_UNSIGNED_BYTE,texture); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); } Madhulika (18010), Assistant Professor, LPU.

Madhulika (18010), Assistant Professor, LPU. void display(void) { glClearColor(1.0,1.0,0.0,0.0); glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_TRIANGLES); glTexCoord2f(4, 8); glVertex2f(3, 3); glTexCoord2f(0.0, 0.0); glVertex2f(0, 0); glTexCoord2f(8, 0.0); glVertex2f(3, 0); glEnd(); glFlush(); } int main(int argc,char** argv){ glutInit(&argc,argv); glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); glutInitWindowSize(600,600); glutInitWindowPosition(100,100); glutCreateWindow("Texture"); glutDisplayFunc(display); glutReshapeFunc(reshape); glutMainLoop(); } Madhulika (18010), Assistant Professor, LPU.

Madhulika (18010), Assistant Professor, LPU. Thank You Madhulika (18010), Assistant Professor, LPU.