Download presentation

Presentation is loading. Please wait.

Published byGavin O'Connell Modified over 4 years ago

1
9.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 9 Adding Realism Through Texture

2
9.2si31_2001 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
9.3si31_2001 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
9.4si31_2001 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
9.5si31_2001 … or a teapot

6
9.6si31_2001 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

7
9.7si31_2001 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?

8
9.8si31_2001 Texture Mapping - Overview screen space I J object space during scan conversion of each polygon, find corresponding position of pixel on object texture space V U X Y Z paint texture on to object

9
9.9si31_2001 Texture Mapping : Mapping Textures to Objects n We need to establish a mapping from object space (x,y,z) to texture space (u,v) – mapping functions u=f u (x,y,z) and v=f v (x,y,z) – given a point (x,y,z) on object, these functions give us a position (u,v) in texture space object space texture space V U X Y Z paint texture on to object

10
9.10si31_2001 Mapping Texture to Polygons n For polygon texture mapping, we explicitly define the (u,v) co- ordinates of the polygon vertices n That is, we pin the texture at the vertices n We interpolate within the triangle at the time of scan converting into screen space X Z Y object texture space V U

11
9.11si31_2001 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.

12
9.12si31_2001 Interpolation in Texture Space n The interpolation in texture space has to be done carefully n Equal steps in screen space do not correspond to equal steps in object space (and hence texture space) n Why? U V I J screen texture A line is a line in all 3 spaces X Z Y object

13
9.13si31_2001 Interpolation in Texture Space n The rate of change in texture space will depend on the depth of the points from the viewer n Correct approach is to scale by the distance (z P, z Q ) of the points from the viewer U V texture I J screen P Q P Q If Q further away than P, then as we take equal steps from P towards Q, we want to take increasingly large steps in (U,V) space from P to Q.

14
9.14si31_2001 Interpolation in Texture Space n Suppose (u P, v P ) and (u Q,v Q ) are texture co-ords at end-points P, Q n Linear interpolation would be: – u = u Q + (1- )u P with increasing from 0 to 1 (similarly for v) n Correct texture interpolation is: u = [ u Q / z Q + (1- )u P / z P ] / D where D = [ / z Q + (1- )/ z P ] U V texture P Q I J screen P Q Note: this is equivalent to a linear interpolation in projective space

15
9.15si31_2001 Check for Yourself n Suppose P is one unit from viewer, and Q is two units from viewer n Show that the mid- point in screen space is equivalent to one-third of the distance along the line in texture space

16
9.16si31_2001 Texture Mapping to an Object n How do we map to an entire object - rather than a polygon? n That is, how do we sensibly assign the texture co-ordinates to the polygon vertices? object space texture space V U X Y Z paint texture on to object

17
9.17si31_2001 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

18
9.18si31_2001 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

19
9.19si31_2001 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

20
9.20si31_2001 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

21
9.21si31_2001 Texture Mapping n This gives us a way of assigning the texture co-ordinates to the polygon vertices n We can then use the texture interpolation at scan conversion time object space texture space V U X Y Z

22
9.22si31_2001 Planar Texture Mapping

23
9.23si31_2001 Cylindrical Texture Mapping

24
9.24si31_2001 Spherical Texture Mapping

25
9.25si31_2001 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

26
9.26si31_2001 Summing Up n We have seen how a 2D texture image can be mapped to an object, at the rendering stage – for a polygon, we pin texture to vertices and interpolate (correctly!) at scan conversion time – assigning texture co-ordinates can be by intermediate mapping 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)

27
9.27si31_2001 Acknowledgements n Thanks to Alan Watt for the images again

Similar presentations

OK

Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung.

Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Sampling Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung.

© 2018 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google

Ppt on uses of plants for grade 1 Ppt on world book day costumes Ppt on web browser and web server Ppt on brain tumor detection Ppt on mass media Convert pdf to ppt online free download Download ppt on oxidation and reduction reaction Ppt on lateral thinking by edward de bono Ppt on teachers training program Ppt on operating system for class 9