texture mapping
play

Texture Mapping CPSC 453 Fall 2018 Sonny Chan Outline for Today - PowerPoint PPT Presentation

Texture Mapping CPSC 453 Fall 2018 Sonny Chan Outline for Today & Friday Motivation Texture mapping function Texture sampling Surface properties Motivation Triangle Geometry? 69400 triangles 251 triangles texture


  1. Texture Mapping CPSC 453 – Fall 2018 Sonny Chan

  2. Outline for Today & Friday • Motivation • Texture mapping function • Texture sampling • Surface properties

  3. Motivation

  4. Triangle Geometry? 69400 triangles 251 triangles texture mapped [from M. Tarini et al. , Computer Graphics Forum 19(3), 2000]

  5. Texture mapping is the use of an image to store and render spatially varying surface properties.

  6. A real world example of a texture mapping problem

  7. Three Sub-Problems • Defining the texture mapping function • Looking up the image values: sampling • Modifying surface properties

  8. The Mapping Function

  9. The Mapping Function • Defined from object space to texture space: φ : S 7! T : ( x, y, z ) 7! ( u, v ) φ

  10. What are the most desirable function characteristics?

  11. Which one is best?

  12. Desirable Characteristics of the Mapping Function • B ij ectivity : mapping function has inverse • Minimal distortion : little stretching or warping • Continuity : adjacent positions map to adjacent texels

  13. Why would we want the function to be bijective?

  14. Bijectivity • Recall our mapping function: φ : S 7! T : ( x, y, z ) 7! ( u, v ) • One-to-many: not possible because it’s a function • Many-to-one: one texture value has influence on properties of many surface points • One-to-one : ideal for optimal control every surface point maps to a different texture image position -

  15. Size Distortion Which is bigger, Australia or Greenland?

  16. Size Distortion • Ideally want the scale of the texture to be roughly constant across the surface Derivatives of φ should not vary much - • Level of detail consistent over the object • More intuitive to create and interpret the texture • Can you think of an instance where you may deliberately want to have size distortion?

  17. Shape Distortion

  18. Shape Distortion • A shape (e.g. a circle) drawn on the object surface would ideally map to the same shape in the texture • Derivatives of φ should be similar in all directions • More intuitive to create and interpret the texture

  19. Is it ever possible to have perfect continuity?

  20. Continuity • Goal is to have a few seams as possible • Put seams in inconspicuous places on the model • Often a trade-off between other characteristics

  21. Texture Mapping Functions • Parametric surfaces • Geometrically determined mappings Planar projection - Spherical or cylindrical mapping - • Manually determined mappings • Mapping a single triangle

  22. What mapping function might suit a parametric surface?

  23. How do we parameterize a sphere?

  24. Which map do we use?

  25. Planar Projection φ ( x, y, z ) = ( x, y ) or u = x v = y

  26. Characteristics of Planar Projection

  27. Spherical Coordinates Works well for “sphere-ish” objects π +tan � 1 ( y x )   2 π φ ( x, y, z ) =   π − cos � 1 ( k x k ) z π

  28. Non-spherical objects?

  29. Cylindrical Coordinates " π +tan − 1 ( y x ) # φ ( x, y, z ) = 2 π 1+ z 2

  30. Complex Shapes What mapping function would we use for an object such as this? [from crossofthedutchman.com]

  31. Hand-Crafted [from crossofthedutchman.com]

  32. The Final Mapping Can you spot the seams?

  33. Texturing a Triangle What mapping function do we use?

  34. Barycentric Coordinates p 2 v ( . 6 , . 4 , 0) p 1 ( . 3 , . 2 , . 5) w u p 0 f ( u, v ) = (1 − u − v ) p 0 + u p 1 + v p 2

  35. Barycentric Mapping p 2 t 2 = ( . 4 , . 8) A 0 p 1 A 1 t 1 = ( . 8 , . 4) ( . 3 , . 2 , . 5) t 0 = ( . 2 , . 2) A 2 p 0 ( u, v ) = 0 . 5 t 0 + 0 . 3 t 1 + 0 . 2 t 2

  36. Texture-Mapped Triangle

  37. Mapping Function Summary • Goal is to define a function from the object to the image ideally continuous, bijective, and minimizes distortion - • Standard mapping functions sometimes work well planar projection, spherical mapping, cylindrical mapping - • Complex objects often require hand-crafted functions • Barycentric coordinates are used to interpolate texture values across individual triangles

  38. Texture Sampling reading our values…

  39. What is that setting, anisotropic filtering?

  40. What does this setting do? (Borderlands 2, 2K Games)

  41. Texture Footprint: Texel to Pixel Ratio φ φ rendered image texture map Are the texels larger or smaller than the pixels?

  42. Texture Magnification one texel → many pixels What is our main challenge?

  43. Image Reconstruction: An Interpolation Problem nearest linear sinc

  44. Texture Minification many texels → one pixel What is our main challenge?

  45. 1 1 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 -1 -1 Aliasing!!! 🙂 1 0 1 2 3 4 5 6 7 8 9 10 11 -1

  46. Anti-Aliasing Textures How do we do it? No jaggies!

  47. Anti-Aliasing Textures How do we do it? No jaggies!

  48. How much do we blur?

  49. Texture Filtering How many texture image pixels does this screen pixel cover? [from johnwhigham.blogspot.ca]

  50. Mipmaps • multum in parvo • Construct layers, each half the size of the previous, to form an image pyramid • Choose pyramid level depending on footprint • What is the highest frequency content of each level?

  51. Revisiting the Texture Footprint mipmap sampling

  52. Anisotropic Filtering 4x anisotropic filtering

  53. Texture Sampling/Filtering Summary • Must choose the right strategy depending on the pixel!

  54. Texture Sampling/Filtering Summary • Must choose the right strategy depending on the pixel! • Magnification is an interpolation problem • Magnification is an anti-aliasing problem

  55. Surface Properties What can we texture map?

  56. Our heuristic shading equation from last week… • with ambient, diffuse, and specular terms: ⌘ p ⇣ ⌘ ⇣ n · ˆ ˆ c = c r c a + c l max(0 , ˆ l ) + c l c p h · ˆ n c r is reflectance (diffuse) colour of material • c p is specular colour of material • p is Phong exponent, or shininess of material • c l is light source intensity (colour) • c a is ambient light intensity (colour) •

  57. Colour or Diffuse Maps

  58. Specular Maps

  59. Specular Maps [from kay-vriend.blogspot.ca]

  60. Normal Maps [from kay-vriend.blogspot.ca]

  61. Bump Maps [from kay-vriend.blogspot.ca]

  62. Bump Maps

  63. Light Maps Quake 2, id software

  64. Light Maps

  65. Rendered Result Putting all the maps together…

  66. Rendered Result Oops, did we break the illusion?

  67. Things to Remember • Texture mapping involves defining a mapping function, sampling the image, and applying the texture values • Mapping functions balance bijectivity, continuity, and minimizing distortion • Interpolation and anti-aliasing play an important role in high-quality texture sampling • Texture mapping can be used to modify any surface property that appears in our lighting equation!

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend