textures – magnification and minification lecture 30 mon, nov 17, 2003
TRANSCRIPT
![Page 1: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/1.jpg)
Textures – Magnification and Minification
Lecture 30Mon, Nov 17, 2003
![Page 2: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/2.jpg)
Magnification and Minification
Ideally, the mapping of texels to pixels would be one-to-one.Here we run into two problems. A small region of texels may be
mapped to a large region of pixels (magnification).
A large region of texels may be mapped to a small region of pixels (minification).
![Page 3: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/3.jpg)
Magnification
In magnification, one texel is mapped to many pixels.
a few texels
many pixels
1 to 16
![Page 4: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/4.jpg)
Minification
In minification, many texels are mapped to one pixel.
many texels
a few pixels
16 to 1
![Page 5: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/5.jpg)
Calculating the Texel
Suppose the polygon (rectangle) goes from (xmin, ymin) in the lower left to (xmax, ymax) in the upper right.Then pixel coordinates (x, y) correspond to texture coordinates s = (x – xmin)/(xmax – xmin). t = (y – ymni)/(ymax – ymin).
![Page 6: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/6.jpg)
Calculating the Texel
Then multiply s and t by the dimensions of the texture, e.g., 64 64.Typically, the results are not integers.So we have a choice. Round them to the nearest integers and
use that single texel. Use the fractional values to interpolate
among the nearest 2 2 array of texels.
![Page 7: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/7.jpg)
Magnification and Minification
Run Nate Robin’s tutorial by shrinking the texture region down to a small rectangle.Then expand the texture region and shrink the pixel region down to a small rectangle.Tutors
![Page 8: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/8.jpg)
Magnification
pixels
texels
The alignment is probably not exact.
![Page 9: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/9.jpg)
Nearest Texel
pixels
texels
Find the nearest texel.
![Page 10: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/10.jpg)
Nearest Texel
pixels
texels
Find the nearest texel.
![Page 11: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/11.jpg)
Linear Interpolation
OpenGL may also interpolate the colors of the nearest four texels.
![Page 12: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/12.jpg)
Linear Interpolation
pixels
texels
Find the nearest four texels.
![Page 13: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/13.jpg)
Linear Interpolation
pixels
texels
Find the nearest four texels.
![Page 14: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/14.jpg)
Example: Interpolation
Using the nearest texel, color the pixels.
80
0
8
x
y s
t
![Page 15: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/15.jpg)
Example: Interpolation
Compute the color of the pixel (2, 4).Assume the texture is 2 2.The center of the pixel is 25% of the way across the group of
texels. Therefore, s = 0.25. 50% of the way up the group of texels. Therefore, t = 0.50.
![Page 16: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/16.jpg)
Example: Interpolation
Interpolate horizontally.Top edge: 0.75(1, 0, 0) + 0.25(0, 1, 0) = (0.75, 0.25,
0).
Bottom edge: 0.75(0, 0, 1) + 0.25(1, 1, 0) = (0.25, 0.25,
0.75).
![Page 17: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/17.jpg)
Example: Interpolation
Now interpolate those values vertically: 0.5(0.75, 0.25, 0) + 0.5(0.25, 0.25,
0.75)= (0.5, 0.25, 0.375).
![Page 18: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/18.jpg)
Interpolation
This is very similar to the interpolation used to shade a triangle except that The triangle used barycentric
coordinates. The texture uses bilinear interpolation
in rectangular coordinates.
![Page 19: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/19.jpg)
Example
TextureDemo.cpp.RgbImage.cpp.Press ‘N’ to toggle between GL_NEAREST and GL_LINEAR.
![Page 20: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/20.jpg)
Minification
one pixel
texels
Again, the alignment is not exact.
![Page 21: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/21.jpg)
Minification
If 64 texels all map to the single pixel, what color should the pixel be?
?
![Page 22: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/22.jpg)
Minification
Again, we may choose between the nearest texel and interpolating among the nearest four texels.
![Page 23: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/23.jpg)
Nearest Texel
If we choose to use the nearest texel, then OpenGL uses the color of the texel whose center is nearest to the center of the pixel.This can lead to “shimmering” and other effects if adjacent pixels have very different colors, as in the checkerboard example.
![Page 24: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/24.jpg)
Minification
one pixel
texels
Choose the nearest texel.
![Page 25: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/25.jpg)
Minification
If we choose to interpolate, then OpenGL will compute the average of the four texels that whose centers are nearest to the center of the pixel.This will reduce, but not eliminate, the shimmering and other effects.
![Page 26: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/26.jpg)
Minification
one pixel
texels
Choose the four nearest texels.
![Page 27: Textures – Magnification and Minification Lecture 30 Mon, Nov 17, 2003](https://reader030.vdocuments.us/reader030/viewer/2022032705/56649dda5503460f94ad12af/html5/thumbnails/27.jpg)
Minification
64 texels one pixel