Presentation is loading. Please wait.

Presentation is loading. Please wait.

Cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam Texture Mapping Beautification of Surfaces 1/23.

Similar presentations


Presentation on theme: "Cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam Texture Mapping Beautification of Surfaces 1/23."— Presentation transcript:

1 cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam Texture Mapping Beautification of Surfaces 1/23

2 cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam  Texture mapping:  Implemented in hardware on every GPU  Simplest surface detail hack, dating back to the ‘60s GE flight simulator and its terrain generator  Technique:  “Paste” photograph or bitmap (the texture, for example: a brick pattern, a wood grain pattern, a sky with clouds) on a surface to add detail without adding more polygons  Map texture onto surface, get surface color or alter the object’s surface color  Think of texture map as stretchable contact paper November 4, 2014 Texture Mapping Overview (1/3) 2/23

3 cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam  How do we add more detail to a model?  Add more detailed geometry; more, smaller triangles:  Pros: Responds realistically to lighting, other surface interaction  Cons: Difficult to generate, takes longer to render, takes more memory space  Map a texture to a model:  Pros: Can be stored once and reused, easily compressed to reduce size, rendered very quickly, very intuitive to use, especially useful on far-away objects, terrain, sky,…”billboards” used extensively in games  Cons: Very crude approximation of real life. Texture mapped but otherwise unaltered surfaces still look smooth. Need to perspectivize/filter for real effectiveness  What can you put in a texture map? (or any other kind of map?)  Diffuse, ambient, specular, or any kind of color  Specular exponents, transparency or reflectivity coefficients  Surface normal data (for normal mapping or bump mapping – stay tuned)  Projected reflections or shadows November 4, 2014 Texture Mapping Overview (2/3: Motivation) 3/23

4 cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam  A function is a mapping  Takes any value in the domain as an input and outputs (“maps it to”) one unique value in the co-domain.  Mappings in “Intersect”: linear transformations with matrices  Map screen space points (input) to camera space rays (output)  Map camera space rays into world space rays  Map world space rays into un-transformed object space for intersecting  Map intersection point normals to world space for lighting  Mapping a texture:  Take points on the surface of an object (domain)  Return an entry in the texture (co-domain) November 4, 2014 Texture Mapping Overview (3/3: Mappings) 4/23

5 cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam  Texture mapping is process of mapping a geometric point in space to a value (color, normal, other…) in a texture map of arbitrary width and height  Our goal is to map any arbitrary geometry to a texture map  Done in two steps:  Map a point on geometry to a point on unit square (a proxy for texture map)  Map unit square point to point on texture  Second mapping much easier, we’ll cover it first – both maps based on proportionality  Note 1: this 2D uv coordinate system is unrelated to the camera’s 3D uvw coordinate system!  Note 2: In this lecture, show unit square oriented with (0,0) in the bottom corner. However, most images have (0,0) in upper left. In Ray, use the latter – simple adjustment November 4, 2014 Texture Mapping Technique (1/8) (0.0, 0.0) (1.0, 1.0) Van Gogh 5/23

6 cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam November 4, 2014 Texture Mapping Technique (2/8) 6/23 (1.0, 1.0) (0.0, 0.0) unit texture square (200, 100) (0, 0) texture map

7 cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam November 4, 2014 Texture Mapping Technique (3/8) 7/23

8 cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam  Texture mapping in “Ray”: mapping solids  Using ray tracing, get an intersection point (x, y, z) in object space  Need to map this point to a point on the (u, v) unit square, so we can map that to a texture value  Three easy cases: planes, cylinders, and spheres  Easiest to compute the mapping from (x, y, z) coordinates in object space to (u, v)  Can cause unwanted texture scaling  Texture filtering is an option in most graphics libraries  OpenGL allows you to choose filtering method  GL_NEAREST: Picks the nearest pixel in the texture  GL_LINEAR: Weighted average of the 4 nearest pixels November 4, 2014 Texture Mapping Technique (4/8): Mapping from point on object to (u, v) square 8/23

9 cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam November 4, 2014 Texture Mapping Technique (5/8) 9/23 y x (w, h) (0, 0) v u (1.0, 1.0) Infinite plane Unit plane Note: C/C++ do not allow non-integer moduli. In code, w and h must be integers.

10 cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam November 4, 2014 Texture Mapping Technique (6/8) P x y z x z P http://www.syvum.com/iosundry/tea sers/cylind1b.gif 10/23

11 cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam November 4, 2014 Texture Mapping Technique (7/8) 11/23

12 cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam November 4, 2014 Texture Mapping Technique (8/8) 12/23 uvuv

13 cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam  We want to create a brick wall with a brick pattern texture  A brick pattern is very repetitive, we can use a small texture and “tile” it across the wall November 4, 2014 Texture Mapping Style - Tiling Without Tiling With Tiling Texture  Tiling allows you to scale repetitive textures to make texture elements just the right size. 13/23

14 cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam  With non-repetitive textures, we have less flexibility  Have to fill an arbitrarily large object with a texture of finite size  Can’t tile (will be noticeable), have to stretch instead  Example, creating a sky backdrop: November 4, 2014 Texture Mapping Style - Stretching Texture Applied with stretching 14/23

15 cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam November 4, 2014 Texture Mapping Complex Geometry (1/5) 15/23

16 cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam November 4, 2014 Texture Mapping Complex Geometry (2/5) 16/23

17 cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam November 4, 2014 Texture Mapping Complex Geometry (3/5) 17/23 roof intersection point = large radius bottom intersection point = small radius

18 cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam November 4, 2014 Texture Mapping Complex Geometry (4/5) 18/23

19 cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam November 4, 2014 Texture Mapping Complex Geometry (5/5) 19/23 SphericalAutomaticCylindrical Images by Vivian Morgowicz Rendered in Maya on the CS125 lighting stage = Planar = = Handmade

20 cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam  Say we have a triangle mesh  And we’ve defined colors at vertices of triangles  How do we define colors of pixels that are on interior or edges of triangle?  Interpolating colors in triangle can be done using “scanline” interpolation of scanline extrema, but is made easier by using Barycentric coordinates  define a point on a triangle in terms of its 3 vertices  then use this representation to choose appropriate color  Many applications  Mesh Colors (painting textures on to arbitrary meshes):  Cem Yuksel, John Keyser, and Donald H. House Mesh Colors ACM Transactions on Graphics (TOG), Vol. 29, No. 2, 2010  Take CS224 November 4, 2014 Barycentric Coordinates ? 20/23

21 cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam November 4, 2014 Barycentric Coordinates 21/23

22 cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam November 4, 2014 Applying Barycentric Coordinates (1/2) http://mathworld.wolfram.com/ima ges/eps-gif/Barycentric_901.gif 22/23 t i is a weight proporti0nal to distance, not just the distance

23 cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam November 4, 2014 Applying Barycentric Coordinates (2/2) http://mathworld.wolfram.com/ima ges/eps-gif/Barycentric_901.gif 23/23


Download ppt "Cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam Texture Mapping Beautification of Surfaces 1/23."

Similar presentations


Ads by Google