Mipmaps Lecture 16 Mon, Oct 1, 2007.

Slides:



Advertisements
Similar presentations
CSE 781 Anti-aliasing for Texture Mapping. Quality considerations So far we just mapped one point – results in bad aliasing (resampling problems) We really.
Advertisements

OpenGL Texture Mapping
Texture Mapping. Typical application: mapping images on geometry 3D geometry (quads mesh) + RGB texture 2D (color-map) =
Week 7 - Wednesday.  What did we talk about last time?  Transparency  Gamma correction  Started texturing.
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.
Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003.
Computer Graphics Inf4/MSc Computer Graphics Lecture 9 Antialiasing, Texture Mapping.
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
Introduction to Texture Mapping CSE 470/598 Introduction to Computer Graphics Arizona State University Dianne Hansford.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Computer Graphics Texture Mapping
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.
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)
ECSE-4750 Computer Graphics Fall 2004 Prof. Michael Wozny TA. Abhishek Gattani TA. Stephen
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.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
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.
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!
1 Graphics CSCI 343, Fall 2015 Lecture 25 Texture Mapping.
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.
ITEC2110, Digital Media Chapter 2 Fundamentals of Digital Imaging 1 GGC -- ITEC Digital Media.
Antialiasing. What is alias? Alias - A false signal in telecommunication links from beats between signal frequency and sampling frequency (from dictionary.com)
Texture Mapping Sung-Eui Yoon (윤성의) CS380: Computer Graphics
Week 7 - Wednesday CS361.
Madhulika (18010), Assistant Professor, LPU.
Week 7 - Monday CS361.
Texture Mapping 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
OpenGL Texture Mapping
Graphics, Fall 2017 Lecture 24: Texture Mapping
Anti-aliasing for Texture Mapping
texturing a parametric surface
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
(c) University of Wisconsin, CS 559
3D Game Programming Texture Mapping
Textures II Week 10, Mon Mar 22
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Procedural Animation Lecture 6: Mapping
ATCM 6317 Procedural Animation
Introduction to Meshes
Textures Lecture 11 Wed, Oct 5, 2005.
Computer Graphics Practical Lesson 6
OpenGL Texture Mapping
OpenGL Texture Mapping
Advanced Computer Graphics: Texture
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
Introduction to Meshes
Presentation transcript:

Mipmaps Lecture 16 Mon, Oct 1, 2007

Discrete Sampling A mipmap is intended to solve a problem created by discrete sampling. Suppose we are drawing a 2-dimensional black and white checkerboard pattern. Suppose that when the surface is close enough to the camera and oriented just right that each texel matches exactly one pixel.

Discrete Sampling Consider one row of pixels and texels, where the pixels and texels are the same size. texels pixels

Discrete Sampling Using the nearest texel, the pixels will be colored alternately black and white. texels pixels

Discrete Sampling What if the texels were ever so slightly smaller than the pixels?. texels pixels

Discrete Sampling What if the texels were ever so slightly smaller than the pixels?. texels pixels

Discrete Sampling Now suppose the surface moves a little further away so that nearly 2 texels cover one pixel. texels pixels

Discrete Sampling Using the nearest texel, there will be long stretches of black and white pixels. texels pixels

Discrete Sampling What will happen when the texels are exactly half the width of a pixel? What will happen when the texels are exactly one third the width of a pixel? Exactly one fourth?

Mipmaps To solve this problem, we may construct a mipmap. mip = multum in parvo = “many things in a small place.” Rather than use the nearest texels or the average of the four texels that happen to be nearest to the pixel, we can create smaller and smaller copies of the entire texture.

Mipmaps If the original texture is 64  64, then we should create copies at the scales of 32  32, 16  16, 8  8, 4  4, 2  2, and 1  1. If the original texture is 64  16, then we should create copies at the scales of 32  8, 16  4, 8  2, 4  1, 2  1, and 1  1.

Mipmap Levels The original texture is level 0. The next level is level 1. And so on.

Level 0 Mipmap – 64  64 One texel

Level 1 Mipmap – 32  32 One texel

Levels 2 – 6 Mipmaps One texel 16 x 16 8 x 8 4 x 4 2 x 2 1 x 1

Level 0 Mipmap – 64  64 One texel

Level 0 Mipmap – 64  64 One texel

Level 1 Mipmap – 32  32 One texel

Level 2 – 6 Mipmaps One texel 16 x 16 8 x 8 4 x 4 2 x 2 1 x 1

Programming Mipmaps Mipmaps are implemented using the same function glTexImage2D() that we used to set the original texture. The second parameter is the level. glTexImage2D(GL_TEXTURE_2D, 0, …, 64, 64, …, image); glTexImage2D(GL_TEXTURE_2D, 1, …, 32, 32, …, image1); glTexImage2D(GL_TEXTURE_2D, 2, …, 16, 16, …, image2); : glTexImage2D(GL_TEXTURE_2D, 6, …, 1, 1, …, image6);

Mipmap Example Read Run

Close-up of Level 0

Close-up of Level 1

Close-up of Level 2

Close-up of Level 3

Close-up of Levels 4, 5, and 6

Using Mipmaps When using mipmaps, we have two separate choices. Whether to use the nearest texel in a mipmap or to interpolate among the 4 nearest texels. Whether to use the nearest mipmap or to interpolate between the nearest two mipmaps.

Using Mipmaps Thus, the choices are Which is the most “expensive”? Nearest texel, nearest mipmap Nearest texel, interpolate mipmaps Interpolate texels, nearest mipmap Interpolate texels, interpolate mipmaps Which is the most “expensive”? Which gives the best results?

Interpolating Between Mipmaps Assume that a single color has been selected from each of the nearest two mipmaps (from either the nearest texel or an average of texels). Compute the scale factor r between the level 0 (original) mipmap and the polygon. Then compute  = log2 r.

Interpolating Between Mipmaps The value of  tells us which mipmap to use. If  = 0, use level 0. If  = 1, use level 1. If  = 2, use level 2, etc. What if  = 1.5? Then we interpolate between level 1 and level 2. Different scale factors may be used for different regions of a single polygon.

Example Suppose  = 1.3 and the level 1 mipmap color is yellow (1, 1, 0) and the level 2 mipmap color is cyan (0, 1, 1). Then the interpolated color is 0.7(1, 1, 0) + 0.3(0, 1, 1) = (0.7, 1.0, 0.3). 0.7 + 0.3 =

Trilinear Interpolation If we interpolate bilinearly within mipmaps and then interpolate those values between mipmaps, we get trilinear interpolation.

Trilinear Interpolation How many individual interpolations are required to perform trilinear interpolation?

Trilinear Interpolation 4 from “left to right” (s direction).

Trilinear Interpolation Plus 2 more from “front to back” (t direction).

Trilinear Interpolation Plus 1 between levels = 7.

Interpolating Mipmaps Use the glTexParameter*() function to set the method of applying mipmap filters. glTexParameteri(GL_TEXTURE_2D, filter, method); The third parameter is GL_NEAREST_MIPMAP_NEAREST GL_NEAREST_MIPMAP_LINEAR GL_LINEAR_MIPMAP_NEAREST GL_LINEAR_MIPMAP_LINEAR

Mipmap Example Read Run code

Generated Mipmaps OpenGL is capable of generating the mipmaps, given the original texture. This is very handy when the original texture is read from a bitmap file. Use the function gluBuild2DMipmaps(). gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, width, height, GL_RGB, GL_UNSIGNED_BYTE, image data);

Generated Mipmaps Read Run