Presentation is loading. Please wait.

Presentation is loading. Please wait.

1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 9 Adding Realism Through Texture.

Similar presentations

Presentation on theme: "1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 9 Adding Realism Through Texture."— Presentation transcript:

1 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 9 Adding Realism Through Texture

2 2GR2-00 Adding Realism plastic floating in air n Objects rendered using Phong reflection model and Gouraud or Phong interpolated shading often appear rather plastic and floating in air plant n Addition of shadows (Lect 8) helps to plant the objects on a ground surface texture n In this lecture we look at how texture effects can be added to give more realistic looking surface appearance

3 3GR2-00 Adding Surface Detail n The most obvious solution is not the best – breaking the scene into smaller and smaller polygonal objects increases the detail –..BUT it is very hard to model and very time-consuming to render n Preferred solution is texture mapping painted – typically a 2D image painted onto objects

4 4GR2-00 A Simple Example n Suppose we have a 2D image... n.. and a 3D box n.. we can paint the image on a face of the box

5 5GR2-00 Basic Concept n Replace the shading calculation with a look-up into a texture map (ie 2D image) to get the colour of a pixel n May replace shaded value - or modulate it in some way

6 6GR2-00 Question n We could apply the texture in screen space (ie after projection) n... or we could apply it in object space (ie before projection) n Which is more sensible?

7 7GR2-00 Texture Mapping - Overview screen space I J texture space object space V U X Y Z

8 8GR2-00 Texture Mapping - Screen to Object n For each screen pixel (i,j), we calculate the corresponding object position (x,y,z) – we can do this during z-buffer rendering – apply inverse transformations to get from projection co-ordinates back to modelling co-ordinates – this gives the corresponding (x,y,z) position n How can we map the texture image to the object?

9 9GR2-00 Texture Mapping - Mapping Textures To Objects n We need to establish a mapping from texture space (u,v) to object space (x,y,z) – mapping functions u = f u (x,y,z) and v = f v (x,y,z) – given a point (x,y,z) on an object, these functions give us a position (u,v) in texture space - and hence an element in the texture image

10 10GR2-00 Texture Mapping - Mapping Textures to Objects n u = f u (x,y,z) n v = f v (x,y,z) n How can we calculate f u and f v ? texture space object space V U X Y Z

11 11GR2-00 Texture Mapping - Two Approaches There are two approaches: n map texture image to entire object ie f u, f v calculated per object n map texture image to each polygonal facet separately ie f u, f v calculated per polygon

12 12GR2-00 Mapping Texture To Object n This is achieved in two stages: simple n first: map texture to a simple bounding shape n second: project from bounding shape onto object itself texture space object space V U X Y Z

13 13GR2-00 Mapping to a Cylinder n A simple bounding object for our bowl is a cylinder n We can wrap the texture around the cylinder as follows: – cylinder radius r, centre origin, has equation x = r cos, y = r sin, z – to wrap texture on to cylinder, we use the mapping functions u = = tan -1 (y/x) v = z

14 14GR2-00 Shrinkwrap n We now need to project from the bounding cylinder to the object shrinkwrapping n A common approach is shrinkwrapping n For an object position (x,y,z), we take the texture of the point (x,y,z) on the bounding cylinder whose normal points at (x,y,z) bounding cylinder 2d cross- section

15 15GR2-00 Intermediate Bounding Surfaces n Other possible intermediate surfaces are: – box, sphere, plane n A simple default action is to calculate bounding box of object, map texture to box, and project from box to object

16 16GR2-00 Planar Texture Mapping

17 17GR2-00 Cylindrical Texture Mapping

18 18GR2-00 Spherical Texture Mapping

19 19GR2-00 Polygon Texture Mapping n This is now increasingly common approach n With each vertex of polygon, associate a texture co-ordinate (x 1,y 1,z 1 ) (x 2,y 2,z 2 ) (x 3,y 3,z 3 ) (u 1,v 1 ) (u 2,v 2 ) (u 3,v 3 ) So: u 1 =f u (x 1,y 1,z 1 ) etc

20 20GR2-00 How to Texture Map Interior n There are now two possibilities: – try to define f u, f v at every interior point (x,y,z) by interpolation in the 3D object space – relate the texture co-ordinates to the pixel positions (i,j) of the projected vertices and interpolate in 2D screen space n Discuss!

21 21GR2-00 Texture Mapping Triangles (x 1,y 1,z 1 ) (x 2,y 2,z 2 ) (x 3,y 3,z 3 ) (u 1,v 1 ) (u 2,v 2 ) (u 3,v 3 ) (i 1,j 1 ) (i 2,j 2 ) (i 3,j 3 ) Interpolation is done during scan conversion, similar as is done for Gouraud interpolated shading But rather than interpolate to get RGB values, we get (u,v) values which point to elements of texture map.

22 22GR2-00 Texture Extent n It is often useful to think of texture space having infinite extent n This can be achieved by replicating the image in texture space V U

23 23GR2-00 Summing Up n We have seen how a 2D texture image can be mapped to an object, at the rendering stage – either per object or per polygon modify n The texture value is used to modify the colour that would otherwise be drawn – options include replacing completely, or modulating (eg by multiplying shaded value with texture value)

24 24GR2-00 Acknowledgements n Thanks to Alan Watt for the images again

Download ppt "1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 9 Adding Realism Through Texture."

Similar presentations

Ads by Google