ECSE-4750 Computer Graphics Fall 2004 Prof. Michael Wozny TA. Abhishek Gattani TA. Stephen

Slides:



Advertisements
Similar presentations
1 Understanding of OpenGL TA: Dong Hyun Jeong Instructor : Dr. Kalpathi Subramanian Texture Mapping.
Advertisements

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
OpenGL Son of the Survival Guide. Last Time on OpenGL Windowing … glut Rendering Primatives Transformations Projections State Management.
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.
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.
Texture Mapping + Texture Object = Texture Mapped Object.
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.
Module 04 – Texture mapping, Texture filtering, Lighting and Blending Module 04 Texture mapping, Texture filtering, Lighting and Blending.
Texture Mapping. Scope Buffers Buffers Various of graphics image Various of graphics image Texture mapping Texture mapping.
Computer Graphics OpenGL - Texture mapping. OpenGL Texture mapping zTexture Mapping allows us to glue an image on polygons. In this method we can produce.
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.
Mapping method Texture Mapping Environmental mapping (sphere mapping) (cube mapping)
An Interactive Introduction to OpenGL Programming Ed Angel
CS 445 / 645 Introduction to Computer Graphics Lecture 19 Texture Maps Lecture 19 Texture Maps.
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.
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 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.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
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,
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.
OpenGL Programming Guide : Texture Mapping Yoo jin wook Korea Univ. Computer Graphics Lab.
OpenGL Graphics Textures. Quiz You didn't see that coming!
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.
Texture Mapping. For Further Reading Angel 7 th Ed: ­Chapter 7: 7.3 ~ 7.9 Beginning WebGL: ­Chapter 3 2.
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.
Madhulika (18010), Assistant Professor, LPU.
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 Computer Graphics with WebGL
Introduction to Texture Mapping
Geb Thomas Adapted from the OpenGL Programming Guide
3D Game Programming Texture Mapping
OpenGL Texture Mapping
OpenGL Texture Mapping
Mipmaps Lecture 13 Wed, Oct 12, 2005.
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:

ECSE-4750 Computer Graphics Fall 2004 Prof. Michael Wozny TA. Abhishek Gattani TA. Stephen

We have discussed Polygons – square, cube, etc. Quadric surfaces – disk, cylinder, sphere etc. Bezier Curves, Bezier Surfaces, B-splines, Nurbs surfaces etc. Based on these basic elements, we can build objects with very complex shape -> render.

Why we need textures? Thousands of small polygons to give the appearance of a real object. Expensive to compute, render and manage Object too smooth and regular to look real Texture mapping allows real images to be applied to objects and is less expensive computationally

Texture Mapping to add realism

Steps in Texture Mapping Create and specify a texture object. Specify texture application method Enable texture mapping mode Draw (map texture co-ordinates to object points)!

Texture Dimensions 2D (common) 1D = 2D with Height =1 – e.g. texture vary only in one direction 3D = Layers of 2D textures – e.g. MRI/CT data Ref: Rosalee Wolfe’s book

Texture Data RGBA Depth Luminance Intensity Texel: one texture element

Texture Application Modes (texture functions) Replace Modulate/Scale Blend

Loading texture data jpeg, png, tiff, gif ?? Idea: convert to BMP and load. Note: Handle all errors when you write I/O code. #include //for reading bitmap image Function prototype – AUX_RGBImageRec *LoadBMP(char *Filename) // Loads A Bitmap Image – Read about AUX_RGBImageRec in more detail.

Loading texture data (contd..) Create a file handle – FILE *File=NULL; // File Handle Try to open the file – File=fopen(Filename,"r"); // Check To See If The File Exists Close the file and load bitmap if (File) // Does The File Exist? { fclose(File); // Close The Handle // Load The Bitmap And Return A Pointer return auxDIBImageLoad (Filename);}

Using the texture data Gluint texture[1]; //Storage for one texture Create Storage Space For The Texture – AUX_RGBImageRec *TextureImage[1]; Load the texture – TextureImage[0]=LoadBMP("Data/NeHe.bmp") Naming a texture object – glGenTextures(1, &texture[0]); – Non-zero unsigned integer may be used as a texture names

Using the texture data (contd..) Bind the named texture to texture target – glBindTexture(GL_TEXTURE_2D, texture[0]); Defined a 2-D Texture – glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);

glTexImage2D void glTexImage2D( GLenum target, //The target texture. Must be GL_TEXTURE_2D. GLint level, //The level-of-detail number. GLint internalformat, //The number of color components in the texture GLsizei width, //Must be 2 n + 2(border) for some integer n. GLsizei height, //Must be 2 m + 2(border) for some integer m. GLint border, //The width of the border. Must be either 0 or 1. GLenum format, //The format of the pixel data. GLenum type, //GL_UNSIGNED_BYTE, GL_BYTE, GL_BITMAP const GLvoid *pixels //pointer to the image data in memory );

Texture Parameters void glTexParameterf(GLenum target, GLenum pname, GLfloat param ); – glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_F ILTER,GL_LINEAR); // Linear Filtering – glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_ FILTER,GL_LINEAR); // Linear Filtering – For GL_TEXTURE_WRAP_S, GL_TEXTURE_WRAP_T you can specify GL_CLAMP or GL_REPEAT.

Free Up Space Image Data if (TextureImage[0])// If Texture Exists { if (TextureImage[0]->data)// If Texture Image Exists { // Free The Texture Image Memory free(TextureImage[0]->data); } free(TextureImage[0]);// Free The Image Structure } Texture Data – void glDeleteTextures( GLsizei n, const GLuint *textures); – Deletes named textures

Changes to Init int InitGL(GLvoid) { if (!LoadGLTextures())// Jump To Texture Loading Routine ( NEW ) { return FALSE;// If Texture Didn't Load Return FALSE ( NEW ) } glEnable(GL_TEXTURE_2D);// Enable Texture Mapping ( NEW ) glShadeModel(GL_SMOOTH);// Enable Smooth Shading glClearColor(0.0f, 0.0f, 0.0f, 0.5f);// Black Background glClearDepth(1.0f);// Depth Buffer Setup glEnable(GL_DEPTH_TEST);// Enables Depth Testing glDepthFunc(GL_LEQUAL);// The Type Of Depth Testing To Do glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);// Really Nice Perspective Calculations return TRUE;// Initialization Went OK } Mode prescedence: Gl_TEXTURE_ID < GL_TEXTURE_2D < GL_TEXTURE_3D < GL_TEXTURE_CUBE_MAP.

Texture Compression Compress While Loading – GL_COMPRESSED_* in internalformat of glTexImage*D Load a Compressed Texture Image – glCompressedTextImage*D – Compression format should be supported by graphics card.

Texture Borders Texture repetition has problems at borders esp. with linear filtering. Each texel has eight neighbors except the borders. So where do edge pixels get their neighbors? From the texture border! Simple approach: Copy the values of the adjacent texture into the border.

Texture rendering Texture mapping is image resampling Some common problems

Mipmaps Why do we need them? – Shimmering, flashing, scintillations when texture is scaled to fit smaller objects in dynamic scenes. Mipmaps: Pre-filtered texture maps at different resolutions OpenGL figures out which map to use when No Free Lunch! Increased storage and computation

Why we need Mipmaps? WithoutWith

Mipmaps

Texture averaging/interpolation Nearest (Linear) – texel nearest to the pixel under consideration Linear (Bilinear) – weighted average of the 4 nearest texels to the pixel under consideration Trade off between image quality and speed

Mipmaps (Contd..) Specifying maps – Manually: glTextImage2D called each time for each map with different parameters – Automatically: build using gluBuild*DMipmaps() gluBuild2DMipmaps(GL_TEXTURE_2D,3,p->sizeX,p- >sizeY,GL_RGB,GL_UNSIGNED_BYTE, p->data)