第三课. Overview of this Section Concept of Texture Mapping ( 纹理映射 ) 2D Texture 3D Texture Environment Mapping Bump Mapping Others OpenGL Implementation.

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.
ATEC Procedural Animation Introduction to Procedural Methods in 3D Computer Animation Dr. Midori Kitagawa.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Textures II Week 8, Wed.
Texture Mapping CPSC /24/03 Abhijeet Ghosh.
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.
Computer Graphics Inf4/MSc Computer Graphics Lecture 11 Texture Mapping.
Texture Mapping A way of adding surface details Two ways can achieve the goal:  Surface detail polygons: create extra polygons to model object details.
1 Computer Graphics Week13 –Shading Models. Shading Models Flat Shading Model: In this technique, each surface is assumed to have one normal vector (usually.
3D Computer Graphics: Textures. Textures: texels Texture is a way of assigning a diffuse color to a pixel – can be with 1, 2 or 3D- can use maps, interpolation.
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.
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. 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
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
Imaging and Raster Primitives Vicki Shreiner. 2 Jobs Andrew Giles Andrew Giles Chuck Fultz Chuck Fultz SIGGraph - SIGGraph.
CS380 LAB IV OpenGL Jonghyeob Lee Reference1. [OpenGL course slides by Rasmus Stenholt] Reference2. [
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 Software College, Shandong University Instructor: Zhou Yuanfeng
Texture Mapping Drawing Pictures on Polygons. Texture Mapping.
Computing & Information Sciences Kansas State University Lecture 10 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.
CG Summary: OpenGL Shading andTextures Angel, Chapters 5, 7; “Red Book” slides from AW, red book, etc. CSCI 6360/4360.
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.
Computer Graphics Bing-Yu Chen National Taiwan University.
1 Graphics CSCI 343, Fall 2015 Lecture 25 Texture Mapping.
Texture Mapping and NURBS Week 7 David Breen Department of Computer Science Drexel University Based on material from Ed Angel, University of New Mexico.
Details of Texture Mapping Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, December 1, 2003.
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.
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
Madhulika (18010), Assistant Professor, LPU.
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
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
OpenGL Texture Mapping
Introduction to Computer Graphics with WebGL
Chapters VIII Image Texturing
(c) University of Wisconsin, CS 559
3D Game Programming Texture Mapping
Computer Graphics Practical Lesson 6
OpenGL Texture Mapping
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
Texture Mapping Jung Lee.
OpenGL Texture Mapping
Presentation transcript:

第三课

Overview of this Section Concept of Texture Mapping ( 纹理映射 ) 2D Texture 3D Texture Environment Mapping Bump Mapping Others OpenGL Implementation

Concept of Texture Mapping

2D Texture Texture is an image, two-dimensional array of color values (texels) Texels are specified by texture’s (u, v) space At each screen pixel, texel can be used to subtitute a polygon’s surface color We mush map (u, v) space to polygon’s (s, t) space

Texture coordinates ( 纹理坐标 ) It is necessary to tell render the texture coordinate for each vertex

Texture coordinates Each polygon can have object coordinates and texture coordinates  Object coordinates describe where polygon vertices are on the screen  Texture coordinates describe texel coordinates of each vertex (usually 0 -> 1)  Texture coordinates are interpolated along vertex-vertex edges

Texture coordinates

3D Texture (Solid Texture) Consider a texture as a function defined over a 3D surface Effective at representing some type of materials such as marble and wood

3D Texture High lights:  Psuedo-random number generation with repeatability in  Smooth  Band-limited (low-pass filter), i.e. rolling hills vs. sharp peaks. Noise Functions: Perlin noise (most popular function) produces noise with the desirable property that the transition from one point to another within the function is a smooth one. [Vase with Perlin noise, Image courtesy of graphics.lcs.mit.edu ]graphics.lcs.mit.edu

3D Texture Fractals ( 分形 statistical self-similarity): A complex object, the complexity of which arises from the repetition of a given shape at a variety of scales.”[tam:apa, pg. 571] Fractal Terrain Generation (Basic idea): 1.Start with a course model (square) 2.Subdivision of surfaces (2x2) 3.Vertically perturb each of the 5 new vertices by a random amount 4.Repeat until done

3D Texture

Analytical Examples: Marble Wood - Vertical cylinders [Procedural wood, both courtesy of [Procedural marble] * i continually increases the noise amplitude animates the Formation of the veins * s,t,r are solid texture coordinates, these are used to do a color map look up for the texture.

Environment Map 环境映射 Use texture to represent reflected color Texture indexed by reflection vector Approximation works when objects are far away from the reflective object Object Viewer Reflected ray Environment Map

Sphere Environment Mapping

Environment Map Cubic Environment Mapping

Environment Map The map should contain a view of the world with the point of interest on the object as the eye  We can ’ t store a separate map for each point, so one map is used with the eye at the center of the object  Introduces distortions in the reflection, but the eye doesn ’ t notice  Distortions are minimized for a small object in a large room The object will not reflect itself The mapping can be computed at each pixel, or only at the vertices

Bump Map 凹凸纹理 Use texture to perturb normals - creates a bump-like effect + = original surface bump map modified surface

Bump Map Physically displace Physically displace  Generate many triangles Simulate Simulate  Change the normal  Normal affects lighting Assume  ‘Bump’ to the surface is small  In the direction of the normal  Height-map

Bump Map Texture used to alter the surface normal Actual shape of the object does not change

Another Example

Bump Map

Treat the texture as a single-valued height function Does not allow silhouette ( 侧面轮廓 ) effects Does not allow self-shadowing

Displace Map Modifies the surface position  Along surface normal, typically Use if Bumps are large Get silhouettes, shadows right Much more expensive  Tessellate geometry  Some support in modern GPUs

Lighting Map 光照图 Use texture to represent illumination footprint

Lighting Map Quake light maps

OpenGL Implementation Specify textures Set texture filter Set texture function Set texture wrap mode Bind texture object Enable texturing Supply texture coordinates for vertex

Define Image as Texture glTexImage2D  Target: type of texture, e.g. GL_TEXTURE_2D  Level: used for mipmapping, 0 for common  Components: elements per texel, 3 for RGB  W, h: width and height of texels in pixels  Border: 0 for common  Format: describe texels, GL_RGB, GL_RGBA  Texels: pointer to texel array

Convert Image to Texture OpenGL requires texture dimensions to be power of 2 (except for High OpenGL version) If not  gluScaleImage(format, w_in, h_in, type_in, *data_in, w_out, h_out, type_out, *data_out);

Mapping a Texture Based on parametric texture coordinates glTexCoord*() specified at each vertex

Typical Code glBegin(GL_POLYGON);  glColor3f(r0, g0, b0); //if no shading  glNormal3f(u0, v0, w0); //if shading  glTexCoord2f(s0, t0);  glVertex3f(x0, y0, z0);  glNormal3f(u1, v1, w1);  glTexCoord2f(s1, t1);  glVertex3f(x1, y1, z1);  … glEnd();

Texture Parameters Wrapping parameters determine what happens if s and t are outside the (0, 1) range Filter modes allow us to use area averaging instead of point sample Mipmapping allows us to use textures at multiple resolutions Environment parameters determine how texture mapping with shading

Wrapping Mode Clamping: if s,t > 1use 1, if s,t < 0 use 0 Repeating: use s,t mod 1  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

Magnification and Minification More than one texel can cover a pixel (min) More than one pixel can cover a texel (mag)

Filter Mode glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

Mipmapped Textures Prefiltered texture maps of decreasing resolutions Lessens interpolation errors for smaller texture objects glTextureImage2D(GL_TEXTURE_2D, level, …); gluBuild2DMipmaps()

Mipmap

Sample Demo application