Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Graphics Inf4/MSc Computer Graphics Lecture 11 Texture Mapping.

Similar presentations


Presentation on theme: "Computer Graphics Inf4/MSc Computer Graphics Lecture 11 Texture Mapping."— Presentation transcript:

1 Computer Graphics Inf4/MSc Computer Graphics Lecture 11 Texture Mapping

2 Computer Graphics Inf4/MSc The Problem: We don't want to represent all this detail with geometry

3 Computer Graphics Inf4/MSc 3 Today Texture mapping –Texture interpolation –Antialiasing : bilinear interpoation, Mipmaps, Common texture coordinates mapping Bump mapping Environment mapping

4 Computer Graphics Inf4/MSc 4 Texture mapping. Method of improving surface appearance by adding details on surface.

5 Computer Graphics Inf4/MSc 5 Texture mapping. Image is ‘pasted’ onto a polygon. Image is called a Texture map, it’s pixels are often referred as a Texels and have coordinates (u,v)‏ Texture coordinates are defined for each vertex of the polygon and interpolated across the polygon. v u v u y x

6 Computer Graphics Inf4/MSc Photo-textures

7 Computer Graphics Inf4/MSc 7 Finding the texture coords of arbitrary pixels inside the triangle y Use the barycentric coordinates explained in Lecture 9

8 Computer Graphics Inf4/MSc Texture Interpolation Specify a texture coordinate (u,v) at each vertex Can we just linearly interpolate the values in screen space? (0,0)‏(1,0)‏ (0,1)‏

9 Computer Graphics Inf4/MSc Interpolation - What Goes Wrong? texture sourcewhat we get|what we want Linear interpolation in screen space:

10 Computer Graphics Inf4/MSc Why does it happen? Uniform steps on the image plane does not correspond to uniform steps along the edge

11 Computer Graphics Inf4/MSc Use a rectangular mesh instead of a triangular mesh or Increase the number of polygons How do we deal with it?

12 Computer Graphics Inf4/MSc 12 Today Texture mapping –Texture interpolation –Antialiasing : bilinear interpoation, Mipmaps, Common texture coordinates mapping Bump mapping Environment mapping

13 Computer Graphics Inf4/MSc 13 Aliasing Happens when –The camera is zoomed too much into the textured surface (magnification)‏ –Several texels covering a pixel’s cell (minification)‏

14 Computer Graphics Inf4/MSc 14 Texture Magnification Zooming into a surface with a texture Methods to determine the color of each pixel –Nearest neighbour –Bilinear interpolation

15 Computer Graphics Inf4/MSc 15 Texture Minification Multiple textures in a single pixel Solution: –Nearest neighbour (using the color at the center of the pixel)‏ –Bilinear blending –Mipmapping

16 Computer Graphics Inf4/MSc Nyquist Limit The texture frequency (ft) should be no greater than half the sample frequency (fs) ft <= 0.5 fs Say it is a 2x2 texture : –Wavelength 2 texels wide –Frequency ft = 1 / 2 –1 / 2 x 2 <= fs, i.e., –To properly display this texture on a screen, the frequency must then be at least 2x 1/2, i.e., at least one pixel per texel

17 Computer Graphics Inf4/MSc 17 MIP map Multum In Parvo = Many things in a small place Produce a texture of multiple resolutions Use the resolution according to the number of texels in one pixel

18 Computer Graphics Inf4/MSc 18 Today Texture mapping –Texture interpolation –Antialiasing : bilinear interpoation, Mipmaps, Common texture coordinates mapping Bump mapping Environment mapping

19 Computer Graphics Inf4/MSc Common Texture Coordinate Mappings Orthogonal Cylindrical Spherical Perspective Projection Texture Chart

20 Computer Graphics Inf4/MSc Demo movie

21 Computer Graphics Inf4/MSc Texture Mapping & Illumination Texture mapping can be used to alter some or all of the constants in the illumination equation: –pixel color, diffuse color, alter the normal, …. Phong’s Illumination Model Constant Diffuse Color Diffuse Texture Color Texture used as LabelTexture used as Diffuse Color

22 Computer Graphics Inf4/MSc 22 Today Texture mapping –Texture interpolation –Antialiasing : bilinear interpoation, Mipmaps, Common texture coordinates mapping Bump mapping Environment mapping

23 Computer Graphics Inf4/MSc What's Missing? What's the difference between a real brick wall and a photograph of the wall texture-mapped onto a plane? What happens if we change the lighting or the camera position?

24 Computer Graphics Inf4/MSc Bump Mapping Use textures to alter the surface normal –Does not change the actual shape of the surface –Just shaded as if it were a different shape Sphere w/Diffuse Texture Swirly Bump Map Sphere w/Diffuse Texture & Bump Map

25 Computer Graphics Inf4/MSc Bump Mapping Treat the texture as a single-valued height function Compute the normal from the partial derivatives in the texture

26 Computer Graphics Inf4/MSc Another Bump Map Example Cylinder w/Diffuse Texture Map Bump Map Cylinder w/Texture Map & Bump Map

27 Computer Graphics Inf4/MSc What's Missing? There are no bumps on the silhouette of a bump-mapped object

28 Computer Graphics Inf4/MSc Displacement Mapping Use the texture map to actually move the surface point The geometry must be displaced before visibility is determined

29 Computer Graphics Inf4/MSc 29 Today Texture mapping –Texture interpolation –Antialiasing : bilinear interpoation, Mipmaps, Common texture coordinates mapping Bump mapping Environment mapping

30 Computer Graphics Inf4/MSc Environment Maps We can simulate reflections by using the direction of the reflected ray to index a spherical texture map at "infinity". Assumes that all reflected rays begin from the same point.

31 Computer Graphics Inf4/MSc Example

32 Computer Graphics Inf4/MSc Environment Mapping Example Terminator II

33 Computer Graphics Inf4/MSc Cubic Mapping The map resides on the surfaces of a cube around the object –align the faces of the cube with the coordinate axes To generate the map: Using methods such as ray tracing –Or, take 6 photos of a real environment with a camera in the object’s position : much easier

34 Computer Graphics Inf4/MSc Calculating the reflection vector Normal vector of the surface : N Incident Ray : I Reflection Ray: R R = I -2 N ( N. I )‏ The texture coordinate is based on the reflection vector Assuming the origin of the vector is always in the center of the cube environment map

35 Computer Graphics Inf4/MSc Indexing Cubic Maps Assume you have R and the cube’s faces are aligned with the coordinate axes, and have texture coordinates in [0,1]x[0,1] –How do you decide which face to use? The reflection vector coordinate with the largest magnitude (0.8, 0.3, 0.2)  face in +x direction –How do you decide which texture coordinates to use? Divide by the coordinate with the largest magnitude Remapped to a value between 0 and 1. (0.8,0.3,0.2)  ((0.3/0.8 +1)*0.5, ((0.2/0.8 +1)*0.5) = (0.6875, 0.625)‏

36 Computer Graphics Inf4/MSc A Sphere Map

37 Computer Graphics Inf4/MSc Sphere Mapping To generate the map: –Take a photograph of a shiny sphere –For synthetic scenes, you can use ray tracing, or warping a cubic environment map

38 Computer Graphics Inf4/MSc Indexing Sphere Maps Given the reflection vector R (s,t) on the spherical map Problems: –Highly non-uniform sampling –Highly non-linear mapping

39 Computer Graphics Inf4/MSc Non-linear Mapping Linear interpolation of texture coordinates picks up the wrong texture pixels –Use small polygons! CorrectLinear

40 Computer Graphics Inf4/MSc Example

41 Computer Graphics Inf4/MSc Refractive Environment Mapping When simulating effects mapping the refracted environment onto translucent materials such as ice or glass, we must use Refractive Environment Mapping

42 Computer Graphics Inf4/MSc Snell’s Law When light passes through a boundary between two materials of different density (air and water, for example), the light’s direction changes. The direction follows Snell’s Law We can do environment mapping using the refracted vector T

43 Computer Graphics Inf4/MSc 43 Summary Texture mapping –Texture interpolation –Antialiasing : bilinear interpoation, Mipmaps, Common texture coordinates mapping Bump mapping Environment mapping

44 Computer Graphics Inf4/MSc 44 Assignment Rendering a head / teapot You may use the 3D rendering function of OpenGL, but better marks are given if you do the illumination by yourself Extra marks given for –Textures, – Environment mapping, –Shadows, mirrors (extra objects)‏ –Global illumination (ray tracing, etc)‏ –Make sure the program runs on DICE


Download ppt "Computer Graphics Inf4/MSc Computer Graphics Lecture 11 Texture Mapping."

Similar presentations


Ads by Google