Texture Mapping What is texture mapping? - a method for adding detail, surface texture (a bitmap or raster image), or color to a computer-generated graphic.

Slides:



Advertisements
Similar presentations
Okay, you have learned … OpenGL drawing Viewport and World Window setup main() { glViewport(0,0,300,200); glMatrixMode(GL_PROJECTION); glLoadIndentity();
Advertisements

1 Introduction to Computer Graphics with WebGL Prof. John Gauch CSCE Department Spring 2015 Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley.
CMPE 466 COMPUTER GRAPHICS
Okay, you have learned … OpenGL drawing Viewport and World Window setup main() { glViewport(0,0,300,200); glMatrixMode(GL_PROJECTION); glLoadIndentity();
Templated Functions. Overloading vs Templating  Overloaded functions allow multiple functions with the same name.
CSC1401 Drawing in Java - 2. Reminder from last class How do you save your modified picture? String filename = …; Picture stevePicture = new Picture(filename);
Eleven colors and rasters. Color objects Meta represents colors with color objects You can create a color by saying: [color r g b] r: amount of red (0-255)
Original image: 512 pixels by 512 pixels. Probe is the size of 1 pixel. Picture is sampled at every pixel ( samples taken)
Mapping between Scene and Screen. Screen (0, W-1) (W-1, H-1) (W-1, 0)(0, 0) Projection Plane (Xmin, Ymin)(Xmax, Ymin) (Xmax, Ymax) (Xmin, Ymax) Screen.
CS 4731: Computer Graphics Lecture 17: Texturing Emmanuel Agu.
Introduction to Computers Section 11A. home Types of Graphics File Bitmap Vector.
OpenGL Pixel Operations, Bitmaps, Fonts and Images The Current Raster Position Current raster position: A position in window coordinates where the next.
Fonts Typeface Typography. Leading Spacing between lines.
Texture Mapping A way of adding surface details Two ways can achieve the goal:  Surface detail polygons: create extra polygons to model object details.
Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University.
Vector Graphics Making custom images. Raster vs. Vector Graphics In computer graphics, a raster graphics image, or bitmap, is a dot matrix data structure.
Texture Mapping. To add surface details… World of Warcraft, Blizzard Inc. More polygons (slow and hard to handle small details) Less polygons but with.
© GCSE Computing Candidates should be able to:  explain the representation of an image as a series of pixels represented in binary  explain the need.
Computer Graphics Texture Mapping Eriq Muhammad Adams
 Scaling an image is resizing the image in a graphic editing software so it is the proper size before adding it to a site.  Important NOTE: If you insert.
Lecture 8: Texture Mapping 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271
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.
Computer Graphics Ben-Gurion University of the Negev Fall 2012.
Shading & Texture. Shading Flat Shading The process of assigning colors to pixels. Smooth Shading Gouraud ShadingPhong Shading Shading.
ECSE-4750 Computer Graphics Fall 2004 Prof. Michael Wozny TA. Abhishek Gattani TA. Stephen
September 21, COMPUTER VISION WEB PAGE IS UP !! OR Simply go to computer science homepage.
Graphics Systems and OpenGL. Business of Generating Images Images are made up of pixels.
Image Representation. Objectives  Bitmaps: resolution, colour depth and simple bitmap file calculations.  Vector graphics: drawing list – objects and.
CG1 Labs Wei Li. Back Face Culling // enable back-face culling glEnable( GL_CULL_FACE ); // orientation of front-facing polygons glFrontFace( GL_CCW );
Chapter 4: Representation of data in computer systems: Images OCR Computing for GCSE © Hodder Education 2011.
Vector Graphics Multimedia Technology. Object Orientated Data Types Created on a computer not by sampling real world information Details are stored on.
CH8 Frame Buffer Object 1. Introduction Name OpenGL :Frame Buffer Object DirectX:Render Target Usage Render to Texture 2.
Computer Graphics Zhen Jiang West Chester University.
Project Two Adding Web Pages, Links, and Images Define and set a home page Add pages to a Web site Describe Dreamweaver's image accessibility features.
Drawing With Lines and Shapes!
XNA Basic Displaying Image & Collision Detect. What’s format image that XNA support? XNA support only.bmp.png and.jpg image..PNG have transparent region.
OpenGL Programming Guide : Texture Mapping Yoo jin wook Korea Univ. Computer Graphics Lab.
CS 325 Introduction to Computer Graphics 04 / 12 / 2010 Instructor: Michael Eckmann.
Graphics 1. Pixel vs Vector 2. Photoshop vs Illustrator vs Fireworks.
Digital Graphics for Computer Games Pixels Types of Digital Graphics (Raster and Vector) Compression.
2. Point A dot; visible mark In typography, a point is a period – the definitive end of a line.
What’s MATH got to do with it??? Graphic Design… Copyright © Texas Education Agency, All rights reserved.
2D drawing basics For CSE 3902 By: Matt Boggus. Overview 2D coordinate systems Raster images Sprite drawing in XNA.
Basic Digital Imaging For PE 266 Technology in HPER.
Multimedia and weBLOGging Grade 7-9 | Cahaya Bangsa Classical School (C) 2010 Digital Media Production Facility 03 - Still Picture 01 – Basics.
Texture Mapping CEng 477 Introduction to Computer Graphics.
Unit 2.6 Data Representation Lesson 3 ‒ Images
COMP261 Lecture 4 Graphs 3 of 3.
Representing images.
Mathematics of the Simple Camera
Basic Raster Graphics Algorithms for Drawing 2D Primitives
Reading Netpbm Images.
Bitmap vs. Vector.
Raster Images CPSC 1030.
What are Range Images?.
texturing a parametric surface
Assignment 3b Q&A.
File Texture Mapping Pasting images on primitives.
Outline Image formats and basic operations Image representation
Images in Binary.
Screen and Image Resolution
String Messy Details Unsigned vs signed.
The Graphics Pipeline Lecture 5 Mon, Sep 3, 2007.
Introduction to OpenGL
2D Graphics Lecture 4 Fri, Aug 31, 2007.
Programming for Art: Images
2 types of scale factor problems
Basic Raster Graphics Algorithms for Drawing 2D Primitives
2.01 Investigate graphic image design.
Programming Textures Lecture 15 Fri, Sep 28, 2007.
Presentation transcript:

Texture Mapping What is texture mapping? - a method for adding detail, surface texture (a bitmap or raster image), or color to a computer-generated graphic or3D modeldetailbitmapraster imagecolorcomputer-generated graphic3D model

Texture Mapping We have to use two headers and cpp files. 1.lodepng.h / lodepng.cpp 2.texture.h / texture.cpp

Texture Mapping 1.lodepng.h / lodepng.cpp -We load png files or tga files and convert those into binary files so that VS can read it just as data files we usually use. -We don’t have to know the details.

Texture Mapping 2. texture.h / texture.cpp -What we really have to use -Inside the header file, #ifndef JH_TEXTURE_H #define JH_TEXTURE_H #include unsigned char *loadTGA(const char* filepath, int &width, int &height); void initTGA(GLuint *tex, const char *name, int &width, int &height); void initPNG(GLuint *tex, const char *name, int &width, int &height); void initTex(); #endif

Texture Mapping void initPNG(GLuint *tex, const char *name, int &width, int &height); -tex: the place where we get the converted png file as a binary file -name: the file name (you should write a path to the file) -width: the width of the original png file (in pixel) -height: the height of the original png file (in pixel)

Texture Mapping Usage of initpng function GLuint tex_example; GLuint w; GLuint h; initPNG(&tex_example, “example.png”, w, h); -> convert “example.png” into a binary file which will be in “tex_example”

Texture Mapping Then, What’s in initpng file? void initPNG(GLuint *tex, const char *name, int &width, int &height) { … glDeleteTextures(1, tex); glGenTextures(1, tex); … width = decoder.infoPng.width; height = decoder.infoPng.height; //printf("width: %d height: %d\n", width, height); free(buffer); free(image); } The number 1 is the length of the square where png file will be mapped

Texture Mapping Example, I will use the picture above and its pixel size is 50 times 50.

Texture Mapping After using initpng, what do we have to do? Using same examples as before, glBindTexture(GL_TEXTURE_2D, tex_example); glBegin(GL_QUADS); glTexCoord2i(0.0, 1.0); glVertex2d(Xmin, Ymin); glTexCoord2i(1.0, 1.0); glVertex2d(Xmax, Ymin); glTexCoord2i(1.0, 0.0); glVertex2d(Xmax, Ymax); glTexCoord2i(0.0, 0.0); glVertex2d(Xmin, Ymax); glEnd();

Texture Mapping glTexCoord2i(0.0, 1.0); glVertex2d(Xmin, Ymin); glTexCoord2i(1.0, 1.0); glVertex2d(Xmax, Ymin); glTexCoord2i(1.0, 0.0); glVertex2d(Xmax, Ymax); glTexCoord2i(0.0, 0.0); glVertex2d(Xmin, Ymax); (0, 0) (1, 0) (0, 1)(1, 1) (Xmin, Ymin) (Xmax, Ymax)

Texture Mapping Drawing order is also important. We have to map the points in clockwise or in counter- clockwise manner. Otherwise, the texture mapping isn’t what you expected.

Texture Mapping Assignment 4 -Bezier Surface with Texture mapping -Good Luck