Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.

Similar presentations


Presentation on theme: "1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science."— Presentation transcript:

1 1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science Laboratory University of New Mexico Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

2 Texture Mapping Ed Angel Professor Emeritus of Computer Science University of New Mexico 2 Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

3 3 Objectives Basic mapping strategies ­Forward vs backward mapping ­Point sampling vs area averaging Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

4 4 Is it simple? Although the idea is simple---map an image to a surface---there are 3 or 4 coordinate systems involved 2D image 3D surface Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

5 5 Coordinate Systems Parametric coordinates ­May be used to model curves and surfaces Texture coordinates ­Used to identify points in the image to be mapped Object or World Coordinates ­Conceptually, where the mapping takes place Window Coordinates ­Where the final image is really produced Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

6 6 Texture Mapping parametric coordinates texture coordinates world coordinates window coordinates Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

7 7 Mapping Functions Basic problem is how to find the maps Consider mapping from texture coordinates to a point on a surface Appear to need three functions x = f 1 (s,t) y = f 2 (s,t) z = f 3 (s,t) But we really want to go the other way s t (x,y,z) Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

8 8 Backward Mapping We really want to go backwards ­Given a pixel, we want to know to which point on an object it corresponds ­Given a point on an object, we want to know to which point in the texture it corresponds Need a map of the form s = g 1 (x,y,z) t = g 2 (x,y,z) Such functions are difficult to find in general Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

9 9 Backward Mapping Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015 We can associate texture coordinates manually (see next presentation) ­sometimes it is simple, sometimes not Or we can use mapping functions.

10 10 Two-part mapping One solution to the mapping problem is to first map the texture to a simple intermediate surface First step: map to a known object ­Example : map to cylinder Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

11 11 Second Mapping Second step: map from intermediate object to actual object ­Normals from intermediate to actual ­Normals from actual to intermediate ­Vectors from center of intermediate intermediate actual Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

12 12 Cylindrical Mapping Parametric equations of a cylinder : x = r cos (2  u) y = r sin (2  u) z = v/h They map a rectangle in u,v space to a cylinder of radius r and height h in world coordinates Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015 0 ≤ u ≤ 1 0 ≤ v ≤ 1 If we set : u = s v = t We can then map from texture space. Draw some points on cylinder…

13 13 Spherical Map We can use a parametric sphere x = r cos (2  u) y = r sin (2  u) cos (2  v) z = r sin (2  u) sin (2  v) in a similar manner to the cylinder but have to decide where to put the distortion Spheres are used in environmental maps Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015 0 ≤ u ≤ 1 0 ≤ v ≤ 1 Draw some points on sphere…

14 14 Box Mapping Easy to use with simple orthographic projection Also used in environment maps Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

15 Box Mapping Example Geri’s game 1997 (Pixar)Geri’s game Pixar ­History : http://en.wikipedia.org/wiki/Geri's_Gamehttp://en.wikipedia.org/wiki/Geri's_Game 15 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

16 Box mapping (for Geri’s glass) 16 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

17 Notes The character ressembles actor Jonathan Harris (Lost in space)Jonathan Harris Geri can also be seen in Toy Story 2 https://www.youtube.com/watch?v=Y7lq3qVbP_8 Animators often put « secret » references in their work : ­https://www.youtube.com/watch?v=snuYybp6rqwhttps://www.youtube.com/watch?v=snuYybp6rqw ­https://www.youtube.com/watch?v=lctV3lZCWDAhttps://www.youtube.com/watch?v=lctV3lZCWDA 17 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

18 Pixar debut: Luxo Jr (1986) Luxo jr: https://www.youtube.com/watch?v=6G3O60o5U7w https://www.youtube.com/watch?v=6G3O60o5U7w ­1986 ­History : http://fr.wikipedia.org/wiki/Luxo_Jr.http://fr.wikipedia.org/wiki/Luxo_Jr. ­Why choose a desk lamp ? A simple object on the animator’s desk… ­First time, shades are computed using « shaders »… 18 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

19 Another Application of Box Mapping: Reflection Reflection mapping using a box: ­Good diagram in http://en.wikipedia.org/wiki/Reflection_mapping http://en.wikipedia.org/wiki/Reflection_mapping 19 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

20 20 Aliasing Point sampling of the texture can lead to aliasing errors point samples in u,v (or x,y,z) space point samples in texture space miss blue stripes Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

21 21 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

22 22 Area Averaging A better but slower option is to use area averaging Note that preimage of pixel is curved pixel preimage Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015

23 23 Area Averaging Filtering methods: https://www.filterforge.com/more/help/MainWindow /AntiAliasingMenu.html http://escience.anu.edu.au/lecture/cg/Texture/filteri ngUndersampling.en.html ­(click on next slides…) Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015


Download ppt "1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science."

Similar presentations


Ads by Google