advertisement

lecture16.texturing

67 %
33 %
advertisement
Information about lecture16.texturing
Entertainment

Published on December 12, 2008

Author: aSGuest6422

Source: authorstream.com

advertisement

Texture Mapping : David Luebke 1 12/12/2008 Texture Mapping CS 445: Introduction to Computer Graphics David Luebke University of Virginia Admin : David Luebke 2 12/12/2008 Admin Next assignment out A) Lighting: Phong lighting on the CPU B) NPR: toon shading on the CPU C) GPU programming: lighting & toon shading on the GPU Due April 14 Demo : David Luebke 3 12/12/2008 Demo Wang tiles Recap: Naive Texture Mapping : David Luebke 4 12/12/2008 Recap: Naive Texture Mapping A first cut at a texture-mapping rasterizer: For each pixel: Interpolate u & v using standard edge equations techniques Look up nearest texel in texture map Color pixel according to texel color (possibly modulated by lighting calculations) A serious artifact is warping at the edges of triangles making up the mesh An obvious example: http://graphics.lcs.mit.edu/classes/6.837/F98/Lecture21/Slide06.html Recap: Perspective-Correct Interpolation : David Luebke 5 12/12/2008 Recap: Perspective-Correct Interpolation Skipping some math… Rather than interpolating u and v directly, interpolate u/z and v/z These do interpolate correctly in screen space Also need to interpolate z and multiply per-pixel Problem: we don’t know z anymore Solution: we do know w  1/z So…interpolate uw and vw and w, and compute u = uw/w and v = vw/w for each pixel This unfortunately involves a divide per pixel Texture Map Aliasing : David Luebke 6 12/12/2008 Texture Map Aliasing Naive texture mapping looks blocky, pixelated Problem: using a single texel to color each pixel: int uval = (int) (u * denom + 0.5f); int vval = (int) (v * denom + 0.5f); int pix = texture.getPixel(uval, vval); Actually, each pixel maps to a region in texture If the pixel is larger than a texel, we should average the contribution from multiple texels somehow If the pixel is smaller than a texel, we should interpolate between texel values somehow Even if pixel size  texel size, a pixel will in general fall between four texels An example of a general problem called aliasing Texture Map Antialiasing : David Luebke 7 12/12/2008 Texture Map Antialiasing Use bilinear interpolation to average nearby texel values into a single pixel value (Draw it) Find 4 nearest texture samples Round u & v up and down Interpolate texel values in u Interpolate resulting values in v Also addresses the problem of many pixels projecting to a single texel (Why?) Texture Map Antialiasing : David Luebke 8 12/12/2008 Texture Map Antialiasing What if a single pixel covers many texels? Problem: sampling those texels at a single point (the center of the pixel): Produces Moire patterns in coherent texture (checkers) Leads to flicker or texture crawling as the texture moves Approach: blur the image under the pixel, averaging the contributions of the covered texels But calculating which texels every pixel covers is way too expensive, especially as the texture is compressed Solution: pre-calculate lower-resolution versions of the texture that incorporate this averaging MIP-maps : David Luebke 9 12/12/2008 MIP-maps For a texture of 2n x 2n pixels, compute n-1 textures, each at ½ the resolution of previous: This multiresolution texture is called a MIP-map Generating MIP-maps : David Luebke 10 12/12/2008 Generating MIP-maps Generating a MIP-map from a texture is easy For each texel in level i, average the values of the four corresponding texels in level i-1 If a texture requires n bytes of storage, how much storage will a MIP-map require? Answer: 4n/3 Representing MIP-maps : David Luebke 11 12/12/2008 Representing MIP-maps Trivia: MIP = Multum In Parvo (many things in a small place) Using MIP-maps : David Luebke 12 12/12/2008 Using MIP-maps Each level of the MIP-map represents a pre-blurred version of multiple texels A texel at level n represents 2n original texels When rendering: Figure out the texture coverage of the pixel (i.e., the size of the pixel in texels of the original map) Find the level of the MIP map in which texels average approximately that many original texels Interpolate the value of the four nearest texels Using MIP-maps : David Luebke 13 12/12/2008 Using MIP-maps Even better: Likely, the coverage of the pixel will fall somewhere between the coverage of texels in two adjacent levels of the MIP map Find the pixel’s value in each of the two textures using two bilinear interpolations Using a third interpolation, find a value in between these two values, based on the coverage of the pixel versus each of the MIP-map levels This is (misleadingly?) called trilinear interpolation Using MIP-maps : David Luebke 14 12/12/2008 Using MIP-maps How many interpolations does a texture lookup using trilinear interpolation in a MIP-mapped texture involve? How many texel values from the MIP-map must be fetched for such a lookup? MIP-map Example : David Luebke 15 12/12/2008 MIP-map Example No filtering: MIP-map texturing: Can We Do Better? : David Luebke 16 12/12/2008 Can We Do Better? What assumption does MIP-mapping implicitly make? A: The pixel covers a square region of the texture More exactly, the compression or oversampling rate is the same in u and v Is this a valid assumption? Why or why not? MIP-maps and Signal Processing : David Luebke 17 12/12/2008 MIP-maps and Signal Processing An aside: aliasing and antialiasing are properly topics in sampling theory Nyquist theorem, convolution and reconstruction, filters and filter widths Textures are particularly difficult because a tiled texture can easily generate infinite frequencies E.g., a checkered plane receding to an infinite horizon Using a MIP-map amounts to prefiltering the texture image to reduce artifacts caused by sampling at too low a rate Summed-Area Tables : David Luebke 18 12/12/2008 Summed-Area Tables A technique called summed-area tables lets us integrate texels covered by the pixel more exactly (but still quickly) Details in the book Example: MIP-map texturing Summed-area table texturing Texture Mapping Variations : David Luebke 19 12/12/2008 Texture Mapping Variations A texture can modulate any parameter in the rendering process: Texture asR,G,B: Texture asdiffuse lightingcoefficients: Bump Mapping : David Luebke 20 12/12/2008 Bump Mapping The texture map can even modulate the surface normal used for shading Sphere w/ diffuse texture Swirly bump map Sphere w/ diffuse textureand swirly bump map More Bump Mapping : David Luebke 21 12/12/2008 + = More Bump Mapping How can you tell a bumped-mapped object from an object in which the geometry is explicitly modeled? Last Bump Mapping Example : David Luebke 22 12/12/2008 Last Bump Mapping Example Displacement Map : David Luebke 23 12/12/2008 Displacement Map A displacement map actually displaces the geometry Treats the texture as a height field to be applied to the surface Starting to appear in the interactive graphics pipeline First supported in Matrox Parhelia card Can sort of implement with beta drivers in ATI & NVIDIA cards Will soon appear in all cards Implemented by recursive subdivision of triangles/quads Displacement Map Example : David Luebke 24 12/12/2008 Displacement Map Example What is the biggest visual difference between displacement mapping and bump mapping? Illumination Maps : David Luebke 25 12/12/2008 Illumination Maps Quake introduced illumination maps or light maps to capture lighting effects in video games Texture map: Texture map+ light map: Light map Illumination Maps : David Luebke 26 12/12/2008 Illumination Maps Illumination maps differ from texture maps in that they: Usually apply to only a single surface Are usually fairly low resolution Usually capture just intensity (1 value) rather than color (3 values) Illumination maps can be: Painted by hand: Disney’s Aladdin ride Calculated by a global illumination process: Nintendo64 demo, modern level builders Other Texture Applications : David Luebke 27 12/12/2008 Other Texture Applications Lots of other interesting applications of the texture-map concept (we’ll return to some): Shadow maps 3-D textures (marble, wood, clouds) Procedural textures Environment maps & cube maps For a neat explanation of the first three (with cool applets, as usual) check out: http://graphics.lcs.mit.edu/classes/6.837/F98/Lecture22/Slide21.html

Add a comment

Related presentations

Related pages

Create Detailed and Poseable Character in Adobe ...

Create Detailed and Poseable Character in Adobe Illustrator Average Rating. 4.8 21 ratings Details. 5 Stars ...
Read more

Primary ray - University of Michigan

9/10/98 1 3/23/2004 1 Kinds of rays Lecture 16 • Primary ray – leaves the eye and travels out to the scene • When hit -spawn three new rays to ...
Read more

GAI Term 4 | UArtsy

GAI Term 4. Instructor: Dan Fiske. Danny Williams. Brett Briley. David Lesperance. Paul Liaw. Curriculum Student Projects Course Outline. Project 1: Live ...
Read more

Collin County Community College - Spring Creek ARTC 1325 ...

Improve your grade in Collin County Community College - Spring Creek ARTC 1325 with videos, lecture notes, exams, and interactive tutorials from Learning Ace!
Read more