Lecture 22 Sections 8.8, 8.9, Wed, Oct 28, 2009

Similar documents
GRAFIKA KOMPUTER. ~ M. Ali Fauzi

Graphics. Texture Mapping 고려대학교컴퓨터그래픽스연구실.

Texture Mapping CSCI 4229/5229 Computer Graphics Fall 2016

Textures. Texture Mapping. Bitmap Textures. Basic Texture Techniques

CS212. OpenGL Texture Mapping and Related

Mipmaps. Lecture 23 Subsection Fri, Oct 30, Hampden-Sydney College. Mipmaps. Robb T. Koether. Discrete Sampling.

OpenGL Texture Mapping. Objectives Introduce the OpenGL texture functions and options

Lecture 07: Buffers and Textures

Magnification and Minification

Grafica Computazionale

Texture Mapping. Mike Bailey.

Lecture 19: OpenGL Texture Mapping. CITS3003 Graphics & Animation

CS 432 Interactive Computer Graphics

ก ก ก.

三維繪圖程式設計 3D Graphics Programming Design 第七章基礎材質張貼技術嘉大資工系盧天麒

Chapter 9 Texture Mapping An Overview and an Example Steps in Texture Mapping A Sample Program Specifying the Texture Texture Proxy Replacing All or

CS452/552; EE465/505. Texture Mapping in WebGL

CMSC 425: Lecture 12 Texture Mapping Thursday, Mar 14, 2013

CSC 240 Computer Graphics. Fall 2015 Smith College

Cap. 3 Textures. Mestrado em Engenharia Informática (6931) 1º ano, 1º semestre

IntMu.Lab5. Download all the files available from

Mipmaps. Lecture 35. Robb T. Koether. Hampden-Sydney College. Wed, Nov 18, 2015

CT5510: Computer Graphics. Texture Mapping

Texture Mapping. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

Texture Mapping. Texture Mapping. Map textures to surfaces. Trompe L Oeil ( Deceive the Eye ) The texture. Texture map

Texturas. Objectives. ! Introduce Mapping Methods. ! Consider two basic strategies. Computação Gráfica

Assignment #5: Scalar Field Visualization 3D: Direct Volume Rendering

9.Texture Mapping. Chapter 9. Chapter Objectives

Computational Strategies

Buffers. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

+ = Texturing: Glue n-dimensional images onto geometrical objects. Texturing. Texture magnification. Texture coordinates. Bilinear interpolation

CISC 3620 Lecture 7 Lighting and shading. Topics: Exam results Buffers Texture mapping intro Texture mapping basics WebGL texture mapping

Objectives. Texture Mapping and NURBS Week 7. The Limits of Geometric Modeling. Modeling an Orange. Three Types of Mapping. Modeling an Orange (2)

CSE 167: Introduction to Computer Graphics Lecture #7: Textures. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2018

Assignment #3: Scalar Field Visualization 3D: Cutting Plane, Wireframe Iso-surfacing, and Direct Volume Rendering

Texture Mapping and Sampling

FAKULTI TEKNOLOGI MAKLUMAT DAN KOMUNIKASI BITM INTERACTIVE COMPUTER GRAPHICS LAB SESSION 4. C++ - OpenGL

Lecture 5 3D graphics part 3

Assignment #6 2D Vector Field Visualization Arrow Plot and LIC

CS335 Graphics and Multimedia. Slides adopted from OpenGL Tutorial

CSE 167: Introduction to Computer Graphics Lecture #8: Textures. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2017

Computer Graphics. Three-Dimensional Graphics VI. Guoying Zhao 1 / 73

Discussion 3. PPM loading Texture rendering in OpenGL

CSE 167: Introduction to Computer Graphics Lecture #8: Textures. Jürgen P. Schulze, Ph.D. University of California, San Diego Spring Quarter 2016

Computer Graphics

Texture and other Mappings

Lecture 5. Scan Conversion Textures hw2

... Print PROGRAMS\Final Project final\planes\planeshoot.c 1

Imaging and Raster Primitives

Applying Textures. Lecture 27. Robb T. Koether. Hampden-Sydney College. Fri, Nov 3, 2017

11494 Interactive and GPU Computing Lab. 6-06/05/2015. Textures

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

Steiner- Wallner- Podaras

Texture Mapping. Texture Mapping. Map textures to surfaces. Trompe L Oeil ( Deceive the Eye ) Texture map. The texture

Shading/Texturing. Dr. Scott Schaefer

Texture Mapping. Computer Graphics, 2015 Lecture 9. Johan Nysjö Centre for Image analysis Uppsala University

Computer Graphics. Bing-Yu Chen National Taiwan University

Department of Computer Sciences Graphics Spring 2013 (Lecture 19) Bump Maps

Textures. Datorgrafik 2006

QUESTION 1 [10] 2 COS340-A October/November 2009

Texture Mapping Part 1

Image I/O and OpenGL Textures

Most device that are used to produce images are. dots (pixels) to display the image. This includes CRT monitors, LCDs, laser and dot-matrix

Shading. Flat shading Gouraud shading Phong shading

INF3320 Computer Graphics and Discrete Geometry

Introduction to OpenGL

Methodology for Lecture

Texturing. Slides done bytomas Akenine-Möller and Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY

CS4621/5621 Fall Basics of OpenGL/GLSL Textures Basics

Fog example. Fog is atmospheric effect. Better realism, helps determine distances

Page 6 PROCESSOR PROCESSOR FRAGMENT FRAGMENT. texy[1] texx. texy[1] texx. texy[0] texy[0]

CS179: GPU Programming

Overview. Goals. MipMapping. P5 MipMap Texturing. What are MipMaps. MipMapping in OpenGL. Generating MipMaps Filtering.

Computer Graphics Texture Mapping

Preparing for Texture Access. Stored Texture Shaders. Accessing Texture Maps. Vertex Shader Texture Access

Stored Texture Shaders

Chapter 3. Texture mapping. Learning Goals: Assignment Lab 3: Implement a single program, which fulfills the requirements:

Computergraphics Exercise 15/ Shading & Texturing

OpenCL / OpenGL Texture Interoperability: An Image Blurring Case Study

CSE 167: Introduction to Computer Graphics Lecture #9: Textures. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013

三維繪圖程式設計 3D Graphics Programming Design 第六章 Bitmap 影像及圖檔格式設定嘉大資工系盧天麒

CSE 167: Lecture 11: Textures 2. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

Mar :51 gltexobj.cpp

General Purpose computation on GPUs. Liangjun Zhang 2/23/2005

Building a 3D World. From a Couple of Lectures Ago. A More Flexible Approach. Lots of little details. We discussed OpenGL imaging functions:

To Do. Review of Last Demo. Methodology for Lecture. Geometry Basic Setup. Outline. Foundations of Computer Graphics (Fall 2012)

Overview. By end of the week:

Texture Mapping 1/34

Texturing. Slides done by Tomas Akenine-Möller and Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Workshop 3D capture, modelling and augmented reality Capture 3D, modélisation et réalité augmentée

Texture Mapping. Texture (images) lecture 16. Texture mapping Aliasing (and anti-aliasing) Adding texture improves realism.

lecture 16 Texture mapping Aliasing (and anti-aliasing)

Texture. No Textures

Lecture 6 Sections 4.3, 4.6, 4.7. Wed, Sep 9, 2009

LSU EE Homework 3 Solution Due: 12 October 2015

1)Write a shader program that renders a regular pentagon with textured image like the one shown below.

Lighting and Texturing

Pointers. Lecture 1 Sections Robb T. Koether. Hampden-Sydney College. Wed, Jan 14, 2015

Computer Graphics Texture Mapping

Transcription:

s The s Lecture 22 Sections 8.8, 8.9, 8.10 Hampden-Sydney College Wed, Oct 28, 2009

Outline s The 1 2 3 4 5 The 6 7 8

Outline s The 1 2 3 4 5 The 6 7 8

Creating Images s The To create a texture image internally, create a 3-dimensional array of unsigned bytes (chars) First dimension = row number Second dimension = column number Third dimension = RGB level Assign to each byte a value from 0 to 255.

Creating a Images s The Example (Creating a Image) GLubyte image[64][64][3]; void makeimage() { // Make a 64 x 64 black and white checkerboard for (int i = 0; i < 64; i++) for (int j = 0; j < 64; j++) if ((i & 0x8) ˆ (j & 0x8)) for (int k = 0; k < 3; k++) image[i][j][k] = 0; else for (int k = 0; k < 3; k++) image[i][j][k] = 255; return; }

Creating Images s The A checkerboard texture

Storing s in s The The function glpixelstore*() tells how texels are stored in texture memory. 1 = on byte boundaries. 2 = on even-numbered byte boundaries. 4 = on word boundaries. 8 = on double-word boundaries. We will use glpixelstorei(gl_unpack_alignment, 1);

Storing s in s The The function glteximage2d() stores the image in texture memory. glteximage2d(gl_texture_2d, level, internal format, width, height, border, image format, image type, ptr to image);

s The level is used if we are supplying multiple levels of detail, 0 otherwise. internal format is usually GL_RGB or GL_RGBA. width and height must be powers of two. border is 0 if there is no border, 1 otherwise. image format is the format of the data in the external image array, usually GL_RGB or GL_RGBA. image type is the data type of each value in the image array, usually unsigned byte. ptr to image is a pointer to the array of texels.

s The A typical function call is glteximage2d(gl_texture_2d, 0, GL_RGB, 64, 64, 0, GL_RGB, GL_UNSIGNED_BYTE, image);

Outline s The 1 2 3 4 5 The 6 7 8

s The Each texture has its own coordinate system. s is the horizontal axis. t is the vertical axis. The texture coordinates are always 0 s 1, 0 t 1. 1 t 0 0 1 s

Mapping s to Vertices s The To apply a texture to a polygon, we must map a pair of texture coordinates (s, t) to each vertex (x, y, z) of the polygon. glbegin(gl_quads); gltexcoord2f(0.0, 0.0); glvertex3f(-4.0, -3.0, 0.0); gltexcoord2f(1.0, 0.0); glvertex3f(4.0, -3.0, 0.0); gltexcoord2f(1.0, 1.0); glvertex3f(4.0, 3.0, 0.0); gltexcoord2f(0.0, 1.0); glvertex3f(-4.0, 3.0, 0.0); glend();

Mapping s to Vertices s 1 t 3 y x The 0 0 s 1-3 -4 Mapping textures to vertices 4

Outline s The 1 2 3 4 5 The 6 7 8

s The The function gltexparameter*() is used to set other texture attributes. We can set whether to tile the texture. gltexparameteri(gl_texture_2d, GL_TEXTURE_WRAP_S, GL_REPEAT); We can also use GL_TEXTURE_WRAP_T for the t direction. GL_CLAMP to clamp s or t to [0, 1].

Using GL_REPEAT s The Example (Using GL_REPEAT) glbegin(gl_quads); gltexcoord2f(0.0, 0.0); glvertex3f(-4.0, -3.0, 0.0); gltexcoord2f(4.0, 0.0); glvertex3f(4.0, -3.0, 0.0); gltexcoord2f(4.0, 3.0); glvertex3f(4.0, 3.0, 0.0); gltexcoord2f(0.0, 3.0); glvertex3f(-4.0, 3.0, 0.0); glend();

Applying s s 1 t 3 y The 0 0 1-1 s -3-4 -2 Using GL_REPEAT 4 x

s The We can set whether to interpolate texels. gltexparameteri(gl_texture_2d, GL_TEXTURE_MAG_FILTER, GL_NEAREST); We can also use GL_TEXTURE_MIN_FILTER for minification. GL_LINEAR for interpolation.

Outline s The 1 2 3 4 5 The 6 7 8

Creating s The A texture object consists of An array of texels. The various texture parameters. memory may contain several texture objects (as many as fit). Each object has its own texel array and parameters.

Creating s The A texture object is accessed through a reference number. OpenGL will give us a reference number to the object which we will use to access it.

Creating s The To get a reference number for a single texture, write unsigned int texname; glgens(1, &texname); To get a reference numbers for a several textures, write unsigned int texname[numofs]; glgens(numofs, texname);

Creating s The To create a texture object, use the glbind() function. is used to glbind(gl_texture_2d, texname[i]); The first time this function is called with the texture name texname[i], the texture object is initialized and made the active texture. In all subsequent such calls, texname[i] becomes the active texture.

Outline s The 1 2 3 4 5 The 6 7 8

The s The The texture environment contains a number of texture state variables that apply to all textures. We use the function gltexenv*() to specify the values of the environment variables. We will use the form gltexenvf(gl_texture_env, GL_TEXTURE_ENV_MODE, parameter);

The s The The parameter may take one of the following five values. GL_REPLACE Replace the object color with the texture color. GL_DECAL Replace the object color with the texture color. GL_MODULATE Multiply the object color by the texture color. GL_BLEND Multiply the object color by the reverse of the texture color. GL_ADD Add the texture color to the object color.

Applying s s Finally, textures may be enabled and disabled. glenable(gl_texture_2d); gldisable(gl_texture_2d); The

Outline s The 1 2 3 4 5 The 6 7 8

Brick s Example (Brick ) The code. The executable. The

Multiple s s Example (Multiple s) The code. The executable. The

Outline s The 1 2 3 4 5 The 6 7 8

s The A bitmap file (.bmp) is a file that contains the color of each pixel of a rectangular region. Among other information, the file contains the height and width of the region. See http://en.wikipedia.org/wiki/windows_bitmap

Reading s The The Bitmap class has the following public member functions. readbitmap(filename) - Read the bitmap info from the specified file. imagewidth() - Get the width of the image, in pixels. imageheight() - Get the height of the image, in pixels. imagedata() - Get a pointer to the array of RGB values.

Reading s The We will use the function Bitmap image; image.readbitmap(filename); to read the information from the bitmap file and store the relevant information in a Bitmap object. The Bitmap class assumes that the bitmap file uses 24-bit color. It will not handle other formats.

Reading s The We will use the function the other three member function in the glteximade2d() function. to read the information from the bitmap file and store the relevant information in a Bitmap object. glteximage2d(gl_texture_2d, 0, GL_RGB, image.imagewidth(), image.imageheight(), 0, GL_RGB, GL_UNSIGNED_BYTE, image.imagedata());

Bitmap s s Example (Bitmap s) The code. The executable. The

Outline s The 1 2 3 4 5 The 6 7 8

Homework s The Homework Read Section 8.8 textures in OpenGL. Read Section 8.9 texture generation. Read Section 8.10 environment maps.