Texture Mapping Fall, 2011. Textures Describe color variation in interior of 3D polygon  When scan converting a polygon, vary pixel colors according.

Slides:



Advertisements
Similar presentations
Texture Mapping. Texturing  process that modifies the appearance of each point on a surface using an image or function  any aspect of appearance can.
Advertisements

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
Texture Mapping. Typical application: mapping images on geometry 3D geometry (quads mesh) + RGB texture 2D (color-map) =
Texture Mapping CPSC /24/03 Abhijeet Ghosh.
Computer Graphics (Spring 2008) COMS 4160, Lecture 19: Texture Mapping Many slides from Greg Humphreys, UVA and Rosalee.
OpenGL Texture Mapping
OpenGL Texture Mapping Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
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
2IV60 Computer Graphics set 10: Texture mapping Jack van Wijk TU/e.
11/11/04© University of Wisconsin, CS559 Fall 2004 Last Time Shading Interpolation Texture mapping –Barycentric coordinates for triangles.
1 SIC / CoC / Georgia Tech MAGIC Lab Rossignac Textures and shadows  Generation  Mipmap  Texture coordinates,
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.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 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)
CS 445 / 645 Introduction to Computer Graphics Lecture 19 Texture Maps Lecture 19 Texture Maps.
ECSE-4750 Computer Graphics Fall 2004 Prof. Michael Wozny TA. Abhishek Gattani TA. Stephen
Game Programming (Mapping) Spring.
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.
CS 480/680 Computer Graphics OpenGL Texture Mapping Dr. Frederick C Harris, Jr. Fall 2011.
Texture Mapping Drawing Pictures on Polygons. Texture Mapping.
CHAPTER 8 Color and Texture Mapping © 2008 Cengage Learning EMEA.
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.
1 Graphics CSCI 343, Fall 2015 Lecture 25 Texture Mapping.
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.
Texture Mapping. For Further Reading Angel 7 th Ed: ­Chapter 7: 7.3 ~ 7.9 Beginning WebGL: ­Chapter 3 2.
Greg Humphreys CS445: Intro Graphics University of Virginia, Fall 2003 Texture Mapping Greg Humphreys University of Virginia CS 445, Fall 2003.
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.
Recap Last lecture we looked at local shading models –Diffuse and Phong specular terms –Flat and smooth shading Some things were glossed over –Light source.
Texture Mapping Sung-Eui Yoon (윤성의) CS380: Computer Graphics
Discrete Techniques.
Texture Mapping Fall, 2016.
Texture Mapping cgvr.korea.ac.kr.
Texture Mapping 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
Game Programming (Mapping)
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
OpenGL Texture Mapping
Introduction to Computer Graphics with WebGL
Computer Graphics, Lee Byung-Gook, Dongseo Univ.
Chapters VIII Image Texturing
Geb Thomas Adapted from the OpenGL Programming Guide
3D Game Programming Texture Mapping
Computer Graphics Practical Lesson 6
OpenGL Texture Mapping
Texture Mapping 고려대학교 컴퓨터 그래픽스 연구실.
OpenGL Texture Mapping
Advanced Computer Graphics: Texture
Programming Textures Lecture 15 Fri, Sep 28, 2007.
Adding Surface Detail 고려대학교 컴퓨터 그래픽스 연구실.
3D Game Programming Texture Mapping
Adding Surface Detail 고려대학교 컴퓨터 그래픽스 연구실.
OpenGL Texture Mapping
Presentation transcript:

Texture Mapping Fall, 2011

Textures Describe color variation in interior of 3D polygon  When scan converting a polygon, vary pixel colors according to values fetched from a texture

The Quest for Visual Realism

Surface Textures Add visual detail to surfaces of 3D objects

3D Rendering Pipeline Texture Mapping

Texture Mapping Overview Texture mapping methods  Parameterization  Mapping  Filtering Texture mapping applications  Modulation textures  Illumination mapping  Bump mapping  Environment mapping  Image-based rendering  Non-photorealistic rendering

Parameterization Q: How do we describe where on the geometry each color from the image should go?

Option: Varieties of projections Cylinder MappingSphere MappingCube MappingPlane Mapping

Option: unfold the surface

Option: make an atlas

Texture Mapping Overview Texture mapping methods  Parameterization  Mapping  Filtering Texture mapping applications  Modulation textures  Illumination mapping  Bump mapping  Environment mapping  Image-based rendering  Non-photorealistic rendering

Texture Mapping Steps:  Define texture  Specify mapping from texture to surface  Lookup texture values during scan conversion

Texture Mapping When scan convert, map from …  Image coordinate system (x, y) to  Modeling coordinate system (u, v) to  Texture image (t, s)

Texture Mapping Texture mapping is a 2D projective transformation  Texture coordinate system (t, s) to  Image coordinate system (x, y)

Texture Mapping Scan conversion  Interpolate texture coordinates down/across scan lines  Distortion due to bilinear interpolation approximation Cut polygons into smaller ones, or Perspective divide at each pixel

Texture Mapping Linear interpolationPerspective-correct interpolation

Texture Mapping Overview Texture mapping methods  Parameterization  Mapping  Filtering Texture mapping applications  Modulation textures  Illumination mapping  Bump mapping  Environment mapping  Image-based rendering  Non-photorealistic rendering

Texture Filtering Must sample texture to determine color at each pixel in image

Texture Filtering Aliasing is a problem Point SamplingArea Filtering

Texture Filtering Ideally, use elliptically shaped convolution filters

Texture Filtering Size of filter depends on projection warp  Can prefiltering images Mip maps Summed area tables

Mip Maps Keep textures prefiltered at multiple resolutions  For each pixel, linearly interpolate between two closest levels (e. g. trilinear filtering)  Fast, easy for hardware u v d

Summed-area tables At each texel keep sum of all values down & right  To compute sum of all values within a rectangle, simply subtract two entries  Better ability to capture very oblique projections  But, cannot store values in a single byte

Texture Mapping Overview Texture mapping methods  Parameterization  Mapping  Filtering Texture mapping applications  Modulation textures  Illumination mapping  Bump mapping  Environment mapping  Image-based rendering  Non-photorealistic rendering

Modulation textures Map texture values to scale factor

Illumination Mapping Map texture values to surface material parameter  K A  K D  K S  K T  n Key-framemodelgeometryKey-framemodelgeometry Decal skin Bump skin Gloss skin WOW!ResultWOW!Result ++

Bump Mapping Texture values perturb surface normals geometry Bump map Stores heights: can derive normals + Bump mapped geometry =

Bump Mapping

Displacement Mapping Normal Mapping Problem  Doesn’t take into account geometric surface depth Does not exhibit parallax No self-shadowing of the surface Coarse silhouettes expose the actual geometry being drawn Displacement Mapping  Displace actual positions from Heightfield Map

Displacement Mapping (Result) Displacement Offset

Environment Mapping Texture values are reflected off surface patch

Cube Mapping Cube mapping is the norm nowadays x y z n eye

Image-Based Rendering Map photographics textures to provide details for coarsely detailed polygon model

Solid Textures Texture values indexed by 3D location (x, y, z)  Expensive storage, or  Compute on the fly  ex) Perlin Noise

Texture Mapping Summary Texture mapping methods  Parameterization  Mapping  Filtering Texture mapping applications  Modulation textures  Illumination mapping  Bump mapping  Environment mapping  Image-based rendering  Volume textures

Example) Quake 2 Models: Piece by Piece Model Key Frames Quake 2 interpolates between key frames

Example) Quake 2 Models: Piece by Piece Knight model’s decal skin Texture coordinates map triangles to skin. Note clever packing of decal skin. Only half face because triangles “mirror” the face.

Example) Standard Quake 2: Model Rendering Texture key-frame with decal skin ++ ResultResult Key-framemodelgeometryKey-framemodelgeometry Decal skin

Example) GPU Bump-mapped: Quake 2 Model Rendering! Bump-map model with bump, gloss, & decal skin Key-framemodelgeometryKey-framemodelgeometry Decal skin Bump skin Gloss skin WOW!ResultWOW!Result ++

Example) Quake 2 Bump Mapping: Rendering Passes   ) + ( (( ) = DiffuseDiffuseGlossGlossSpecularSpecularDecalDecal Final result!

Example) More Bump-mapped Knight Examples Different light positions and key-frames All lighting including specular is computed per-fragment!

Example) Bump Mapping Models Viva la difference

OpenGL Texture Mapping Texture Mapping in OpenGL  Allows you to modify the color of a polygon surface  Textures are simply rectangular arrays of data (color, luminance, color+alpha). Individual values in a texture are called texels

OpenGL Texture Mapping : Step Steps necessary to use texture mapping:  Create a texture object and specify the texture  Indicate how the texture is to be applied to each pixel  Enable texture mapping  Draw the scene, supplying both texture and geometric coordinates

OpenGL Texture Mapping : 2D Texture Specification 2D Texture Specification  glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, Glint border, GLenum format, Glenum type, const Glvoid *pixels); target: GL_TEXTURE_2D level: specifies the level of detail when using multi resolution textures. “0” is the base image, “n” is the n-th mipmap reduction image internalFormat: an integer 1 to 4, or one of 38 symbolic constants width, height: the dimensions of the texture (MUST BE power of 2) format: the kind of pixel-data elements type: the data-type of each element pixels: array containing the texture image data Ex) glTexImage2D(GL_TEXTURE_2D, 0, 3, iwidth, iheight, 0, GL_RGB, GL_UNSIGNED_BYTE, image);

OpenGL Texture Mapping : Values for Format and Type Format Constants:  GL_COLOR_INDEX: A single color index  GL_RGB: A red component, followed by green & blue components  GL_RGBA: Like GL_RGB, followed by an alpha component.  GL_RED: A single red-color component  GL_GREEN: A single green-color component  GL_BLUE: A single blue-color component  GL_ALPHA: A single alpha-color component Type Constants:  GL_UNSIGNED_BYTE: unsigned 8-bit integer  GL_BYTE: signed 8-bit integer  GL_UNSIGNED_SHORT: unsigned 16-bit integer  GL_SHORT: signed 16-bit integer  GL_INT: signed 32-bit integer  GL_FLOAT: single-precision floating point

OpenGL Texture Mapping : Texture Coordinates Texture Coordinates  You need to specify BOTH texture & geometric coordinates as you specify the object in your scene glColor3f(1.0f, 0.0f, 0.0f); glBegin(GL_TRIANGLES); glNormal3d(0,0,-1); glTexCoord2d(0,0); glVertex3d(-100,-100,0); glTexCoord2d(1,0); glVertex3d(100,-100,0); glTexCoord2d(0,1); glVertex3d(-100,100,0); glEnd();

OpenGL Texture Mapping : Texture Filtering glTexParameteri( target, type, mode)  Target : GL_TEXTURE_1D, GL_TEXTURE_2D  Type : GL_TEXTURE_MIN_FILTER  Mode : GL_NEAREST, GL_LINEAR, GL_NEAREST_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR GL_LINEAR_MIPMAP_LINEAR  Type : GL_TEXTURE_MAG_FILTER GL_NEAREST or GL_LINEAR Ex) glTexParameteri(GL_TEXTURE_2D, GL_TEXURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXURE_MIN_FILTER, GL_LINEAR);

Min / Max Filter : GL_NEAREST Min / Max Filter : GL_LINEAR No mipmappingMipmappping

OpenGL Texture Mapping : Texture Wrapping glTexParameteri( target, type, mode)  Target : GL_TEXTURE_1D, GL_TEXTURE_2D  Type GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T  mode GL_CLAMP or GL_REPEAT Wrap S : GL_CLAMP Wrap T : GL_CLAMP Wrap S : GL_CLAMP Wrap T : GL_REPEAT Wrap S : GL_REPEAT Wrap T : GL_CLAMP Wrap S : GL_REPEAT Wrap T : GL_REPEAT

OpenGL Texture Mapping : Texturing Functions Texturing Functions  Indicate how the texture is applied to each pixel:  REPLACE or DECAL: Texture is painted on top of the fragment  MODULATE: Combine texture with fragment color. This technique is useful to combine the effects of lighting with texturing  BLEND: A constant color is blended with that of the fragment, based on the texture value Ex) glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);

OpenGL Texture Mapping : Texture Functions