computer graphics course 2006
play

Computer Graphics Course 2006 Texture Mapping Part of the slides - PowerPoint PPT Presentation

Computer Graphics Course 2006 Texture Mapping Part of the slides are by: Raanan Fattal David Akers Durand and Cutler Texture Mapping Motivation Definition of 2D texture mapping Coordinate generation, interpolation Different


  1. Computer Graphics Course 2006 Texture Mapping Part of the slides are by: Raanan Fattal David Akers Durand and Cutler

  2. Texture Mapping � Motivation � Definition of 2D texture mapping � Coordinate generation, interpolation � Different uses of 2D textures � Beyond 2D textures

  3. The Problem: � Motivation: Add interesting and/ or realistic detail to surfaces of objects. � Problem: Fine geometric detail is difficult to model and expensive to render.

  4. The Problem: � We don't want to represent all this detail with geometry

  5. Texture Mapping � Idea: Modify various shading parameters of the surface by mapping a function (such as a 2D image) onto the surface. � Given an image, think of it as a 2D function from [ 0,1] 2 (texture coordinates) to the RGB color space: → → ( , ) ( , , ) ( , ) ( , , ) T u v r g b T u v r g b � For each geometric primitive, define a mapping M that maps points on the surface to texture coordinates: = = ( , , ) ( , ) ( , , ) ( , ) M x y z u v M x y z u v � To shade a pixel corresponding to a point (x,y,z) on the surface, use the color: = = ( , , ) ( , , ) ( ( ( , , )) ( , , )) r g b T M x y z r g b T M x y z

  6. Texture Mapping Example � Texture: � Result:

  7. The Quest for Visual Realism

  8. Texture Mapping � So, what do we have to do in order to make this idea work? � Coordinates generation/ assignment � Interpolation � The basic idea is simple, but… � Large number of details � Still an active research area � We will make an overview of some of the issues today. � Next time you will learn how to use/ implement part of the ideas here with OpenGL

  9. Texture Coordinates � To render a textured triangle, we must start by assigning a texture coordinate to each vertex � A texture coordinate is a 2D point [ t x t y ] in texture space that is the coordinate of the image that will get mapped to a particular vertex

  10. Texture Mapping (1,1) v 1 t 1 y v 0 t 2 t 0 v 2 (0,0) x Texture Space Triangle (in any space)

  11. Texture Interpolation � The actual texture mapping computations take place at the scan conversion and pixel rendering stages of the graphics pipeline � During scan conversion, as we are looping through the pixels of a triangle, we must interpolate the t x t y texture coordinates in a similar way to how we interpolate the rgb color and z depth values � As with all other interpolated values, we must precompute the slopes of each coordinate as they vary across the image pixels in x and y � Once we have the interpolated texture coordinate, we look up that pixel in the texture map and use it to color the pixel

  12. Interpolation for triangles Linear Interpolation: C = λ + − λ ( 1 ) D A C 1 1 = λ + − λ ( 1 ) E B C 2 2 = λ + − λ ( 1 ) F D E 3 3 λ 3 D E Bilinear Interpolation λ 2 F = λ λ + − λ λ 1 ( ( 1 ) ) F A C 3 1 1 B + − λ λ + − λ ( 1 )( ( 1 ) ) B C 3 2 2 = λ + λ + λ F A B C A a b c

  13. Let’s start with the details � Where are a lot of issues with both texture coordinates generation/ assignment and interpolation � Let’s start with the former � Any ideas?

  14. Photo-textures

  15. Texture Mapping Difficulties � Tedious to specify texture coordinates � Acquiring textures is surprisingly difficult � Photographs have projective distortions � Variations in reflectance and illumination � Tiling problems

  16. Painting on textures

  17. Texture Chart � Pack triangles into a single image

  18. What does a texture map for a complex model “look like”?

  19. Texture coordinate generation cube planar spherical cylindrical face shrink-wrap

  20. Parametrizing Objects � Certain objects have a natural parametrization (e.g., Bezier patches) � Polygons (triangles): each vertex is assigned a pair of texture coordinates (u,v). Inside, linear interpolation is used. � How do we handle a more complex object?

  21. Two-Step Texture Mapping (Bier and Sloan 1986) � Step I: define a mapping between the texture and some intermediate surface: � plane � cylinder � sphere � cube � Step II: Project intermediate surface onto object surface

  22. Intermediate Surface Projections

  23. Projective Textures � Use the texture like a slide projector � No need to specify texture coordinates explicitly � A good model for shading variations due to illumination � A fair model for reflectance (can use pictures)

  24. That’s what we get when we just interpolate the coordinates

  25. Magnification and minification m agnification m inification texture polygon texture polygon

  26. Better magnification

  27. Better minification

  28. Another Solution: Mipmapping

  29. Mip-mapping � Mip-mapping � MIP = Multim in Parvo (many things in a small place) � Idea: store texture as a pyramid of progressively lower-resolution images, filtered down from original

  30. Mip-Mapping Depth of Mip-Map

  31. Mip Mapping R G B R G R G B B

  32. Mip Mapping � Which level of mip-map to use? � Think of mip-map as 3-D pyramid � Index into mip-map with 3 coordinates: u, v, d (depth) � The size of the filter (i.e., d in the mip- map) depends on the pixel coverage area in the texture map � In general, treat d as a continuous value � Blend between nearest mip-map level using linear interpolation

  33. Common Artifacts Better results can be achieved with trilinear filtering BTW: do you recognize this head?

  34. Fun stuff � As we already saw in this course, hacks and ad-hoc solutions are part of the CG � Especially in the real-time rendering � Let’s see some really nice and unintended use of mip-maps. � From the Kevin Bjorke(NVIDIA) talk in the GDC.

  35. Color & Depth � I want to create a long tunnel with a haze…

  36. Color & Depth

  37. Color & Depth The “correct”/ analytical way to � achieve the same result is to compute “Facing Ratio”: (N·V) C = lerp(mossColor, texColor, pow(dot(N,V)),expon))

  38. Wrapping up some concepts together… � Is that a good idea to use this chart “as is” with a mip mapping?

  39. Hackish, but… � The evil you see versus the evil you don’t see

  40. What's Missing? � What's the difference between a real brick wall and a photograph of the wall texture-mapped onto a plane? � What happens if we change the lighting or the camera position?

  41. Bump Mapping � Use textures to alter the surface normal � Does not change the actual shape of the surface � Just shaded as if it were a different shape Swirly Bump Map Sphere w/Diffuse Texture & Bump Map Sphere w/Diffuse Texture

  42. Bump Mapping � Treat the texture as a single-valued height function � Compute the normal from the partial derivatives in the texture

  43. Another Bump Map Example Bump Map Cylinder w/Diffuse Texture Map Cylinder w/Texture Map & Bump Map

  44. What's Missing? � There are no bumps on the silhouette of a bump-mapped object � Bump maps don’t allow self-occlusion or self-shadowing

  45. Generalization: Normal Mapping

  46. Displacement Mapping � Use the texture map to actually move the surface point � The geometry must be displaced before visibility is determined

  47. Displacement Mapping Image from: Geometry Caching for Ray-Tracing Displacement Maps by Matt Pharr and Pat Hanrahan . note the detailed shadows cast by the stones

  48. Displacement Mapping Ken Musgrave

  49. Environment Maps � We can simulate reflections by using the direction of the reflected ray to index a spherical texture map at "infinity". � Assumes that all reflected rays begin from the same point.

  50. What's the Best Choice?

  51. Environment Mapping Example Terminator II. Do you remember a movie that used it before that? Hint: same director…

  52. Texture Maps for Illumination (“Static Light Maps“)

  53. Combining textures � One of the basic and prevalent techniques in a (real-time) CG � We will talk more about generalization of those ideas in GPU lesson

  54. Billboarding

  55. Billboarding

  56. Billboarding examples

  57. Billboarding

  58. Solid Textures (Peachey 1985, Perlin 1985) � Problem: mapping a 2D image/ function onto the surface of a general 3D object is a difficult problem: � Distortion � Discontinuities � Idea: use a texture function defined over a 3D domain - the 3D space containing the object � Texture function can be digitized or procedural

  59. Procedural Textures � Advantages: � compact representation (code vs. data) � unlimited resolution � unlimited extent � controllable via parameters � Disadvantages: � Can be difficult to program and debug � Can be difficult to predict and control � Typically slower to evaluate � Can be difficult to pre-filter

  60. .kkrieger � Download and play with it in your spare time.

  61. Questions? Image by Henrik Wann Jensen Environment map by Paul Debevec

Recommend


More recommend