Top Banner
Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 1 / 29
59

Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Apr 17, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

MipmapsLecture 23

Subsection 7.6.5

Robb T. Koether

Hampden-Sydney College

Fri, Oct 28, 2011

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 1 / 29

Page 2: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Outline

1 Discrete Sampling

2 Mipmaps

3 Programming Mipmaps

4 Interpolating between Mipmaps

5 Assignment

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 2 / 29dumay.info

Page 3: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Outline

1 Discrete Sampling

2 Mipmaps

3 Programming Mipmaps

4 Interpolating between Mipmaps

5 Assignment

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 3 / 29dumay.info

Page 4: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Discrete Sampling

Suppose we are drawing a 2-dimensional black-and-whitecheckerboard pattern.Suppose that the surface is close enough to the camera andoriented just right that each texel matches exactly one pixel.

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 4 / 29dumay.info

Page 5: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Discrete Sampling

Consider one row of pixels and texels, where the pixels and texels arethe same size.

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 5 / 29dumay.info

Page 6: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Discrete Sampling

Using the nearest texel, the pixels will be colored alternately black andwhite.

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 5 / 29

Page 7: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Discrete Sampling

Using the nearest texel, the pixels will be colored alternately black andwhite.

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 5 / 29

Page 8: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Discrete Sampling

What if the texels were somewhat smaller than the pixels?

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 6 / 29

Page 9: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Discrete Sampling

What if the texels were somewhat smaller than the pixels?

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 6 / 29

Page 10: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Discrete Sampling

What if the texels were somewhat smaller than the pixels?

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 6 / 29

Page 11: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Discrete Sampling

What if the texels are almost half the size of the pixels?

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 7 / 29

Page 12: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Discrete Sampling

What if the texels are almost half the size of the pixels?

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 7 / 29

Page 13: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Discrete Sampling

Uh oh.

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 7 / 29

Page 14: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Discrete Sampling

What will happen when the texels are exactly half the width of apixel?Exactly one fourth?Exactly one third?

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 8 / 29

Page 15: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Outline

1 Discrete Sampling

2 Mipmaps

3 Programming Mipmaps

4 Interpolating between Mipmaps

5 Assignment

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 9 / 29

Page 16: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Mipmaps

Definition (Mipmap)A mipmap is a reduced copy of a texture, with the colors averaged.

mip = multum in parvo

= “many things in a small place.”

Rather than use the nearest texels or the average of the four texelsthat happen to be nearest to the pixel, we can create smaller andsmaller copies of the entire texture and use their texels.

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 10 / 29

Page 17: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Mipmaps

If the original texture is 64× 64, then we should create copies atthe 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 atthe scales of 32× 8, 16× 4, 8× 2, 4× 1, 2× 1, and 1× 1.

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 11 / 29

Page 18: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Mipmap Levels

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

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 12 / 29

Page 19: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Mipmaps

Onetexel

Level 0 Mipmap - 64× 64

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 13 / 29

Page 20: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Mipmaps

Onetexel

Level 1 Mipmap - 32× 32

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 13 / 29

Page 21: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Mipmaps

Onetexel

Level 2 Mipmap - 16× 16

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 13 / 29

Page 22: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Mipmaps

Onetexel

Level 3 Mipmap - 8× 8

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 13 / 29

Page 23: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Mipmaps

Onetexel

Level 4 Mipmap - 4× 4

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 13 / 29

Page 24: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Mipmaps

Onetexel

Level 5 Mipmap - 2× 2

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 13 / 29

Page 25: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Mipmaps

Onetexel

Level 6 Mipmap - 1× 1

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 13 / 29

Page 26: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Mipmaps

Onetexel

Level 0 Mipmap - 64× 64

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 13 / 29

Page 27: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Mipmaps

Onetexel

Level 0 Mipmap - 64× 64

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 13 / 29

Page 28: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Mipmaps

Onetexel

Level 1 Mipmap - 32× 32

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 13 / 29

Page 29: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Mipmaps

Onetexel

Level 2 Mipmap - 16× 15

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 13 / 29

Page 30: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Mipmaps

Onetexel

Level 3 Mipmap - 8× 8

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 13 / 29

Page 31: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Mipmaps

Onetexel

Level 4 Mipmap - 4× 4

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 13 / 29

Page 32: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Mipmaps

Onetexel

Level 5 Mipmap - 2× 2

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 13 / 29

Page 33: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Mipmaps

Onetexel

Level 6 Mipmap - 1× 1

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 13 / 29

Page 34: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Outline

1 Discrete Sampling

2 Mipmaps

3 Programming Mipmaps

4 Interpolating between Mipmaps

5 Assignment

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 14 / 29

Page 35: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Programming Mipmaps

Mipmaps are implemented using the same functionglTexImage2D() that we used to set the original texture.The second parameter is the level.

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 15 / 29

Page 36: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Screen Shots

Close-up of Level 0

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 16 / 29

Page 37: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Screen Shots

Close-up of Level 1

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 16 / 29

Page 38: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Screen Shots

Close-up of Level 2

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 16 / 29

Page 39: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Screen Shots

Close-up of Level 3

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 16 / 29

Page 40: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Screen Shots

Close-up of Levels 4, 5, and 6

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 16 / 29

Page 41: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Using Mipmaps

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

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 17 / 29

Page 42: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Using Mipmaps

Thus, the combinations of choices areNearest texel and nearest mipmapNearest texel and interpolate mipmapsInterpolate texels and nearest mipmapInterpolate texels and interpolate mipmaps

Which is the most “expensive?”Which gives the best results?

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 18 / 29

Page 43: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Outline

1 Discrete Sampling

2 Mipmaps

3 Programming Mipmaps

4 Interpolating between Mipmaps

5 Assignment

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 19 / 29

Page 44: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Interpolating Between Mipmaps

Assume that a single color has been selected from each of thetwo nearest mipmaps (from either the nearest texel or an averageof texels).Compute the scale factor r between the level 0 (original) mipmapand the polygon.Then compute λ = log2 r .

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 20 / 29

Page 45: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

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 singlepolygon.

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 21 / 29

Page 46: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

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).

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 22 / 29

Page 47: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Trilinear Interpolation

If we interpolate bilinearly within mipmaps and then interpolatethose values between mipmaps, we get trilinear interpolation.

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 23 / 29

Page 48: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Trilinear Interpolation

How many individual interpolations are required?

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 24 / 29

Page 49: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Trilinear Interpolation

0.20 0.80

0.20 0.80

Four in the s direction.

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 24 / 29

Page 50: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Trilinear Interpolation

0.20 0.80

0.20 0.80

Four in the s direction.

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 24 / 29

Page 51: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Trilinear Interpolation

0.60

0.40

0.60

0.40

Two more in the t direction.

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 24 / 29

Page 52: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Trilinear Interpolation

0.60

0.40

0.60

0.40

Two more in the t direction.

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 24 / 29

Page 53: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Trilinear Interpolation

0.60

0.40

One more between the mipmap levels.

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 24 / 29

Page 54: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Trilinear Interpolation

0.60

0.40

One more between the mipmap levels.

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 24 / 29

Page 55: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Trilinear Interpolation

A total of 7 interpolations are required.

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 25 / 29

Page 56: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Interpolating Mipmaps

Use the glTexParameter*() function to set the method ofapplying mipmap filters.

glTexParameteri(GL_TEXTURE_2D, filter, method);

The third parameter is one ofGL_NEAREST_MIPMAP_NEARESTGL_NEAREST_MIPMAP_LINEARGL_LINEAR_MIPMAP_NEARESTGL_LINEAR_MIPMAP_LINEAR

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 26 / 29

Page 57: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Generated Mipmaps

OpenGL is capable of generating the mipmaps, given the originaltexture.This is very handy when the original texture is read from a bitmapfile.Use the function gluBuild2DMipmaps().

gluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGB, width, height, GL_RGB,GL_UNSIGNED_BYTE, image data);

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 27 / 29

Page 58: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Outline

1 Discrete Sampling

2 Mipmaps

3 Programming Mipmaps

4 Interpolating between Mipmaps

5 Assignment

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 28 / 29

Page 59: Lecture 23 Subsection 7.6.5 Robb T. Koether · Mipmaps Lecture 23 Subsection 7.6.5 Robb T. Koether Hampden-Sydney College Fri, Oct 28, 2011 Robb T. Koether (Hampden-Sydney College)

Homework

HomeworkRead Subsection 7.6.5 – Mipmaps.

Robb T. Koether (Hampden-Sydney College) Mipmaps Fri, Oct 28, 2011 29 / 29