Presentation is loading. Please wait.

Presentation is loading. Please wait.

Graphics, Fall 2017 Lecture 24: Texture Mapping

Similar presentations


Presentation on theme: "Graphics, Fall 2017 Lecture 24: Texture Mapping"— Presentation transcript:

1 Graphics, Fall 2017 Lecture 24: Texture Mapping
The Problem with Polygons: To date, we have learned how to create objects using multiple polygonal surfaces. We could use this technique to create complex scenes with many objects, for example a field of grass. Problem: It would take huge amounts of time to render. Polygons tend to look too smooth for some purposes. Many surfaces have lots of variation in them (e.g. carpet, oranges, wood grain).

2 Creating Textured Scenes
To create scenes with lots of variation, we can use a variety of techniques. Among them are: Texture Mapping: Create a texture or pattern and map it onto a surface. Bump Map: Perturb the surface of an object by slightly varying the surface normals. Environmental Map: Map the environment onto a surface (e.g. reflections.

3 Texture Mapping With texture mapping, we map a texture or image onto an object. Creating the texture: Write program to create regular or random texture. OR Load in an image map and use that as the texture. Textures can be in 1, 2 or 3 dimensions: 1-D textures: Map onto a line or curve 2-D textures: Map onto a surface 3-D textures: Map into a volume. Will see texture if take slices through the volume. We will examine only 2-D textures.

4 Representing a Texture
A 2D texture is represented as a 2D pattern: T(s, t) s and t are called texture coordinates. T is stored in a 2D array (n x m) of texture elements, called texels. Textures are rendered as discrete elements. A texture map associates a unique point of T with each point on a geometric object. The object is then mapped to screen coordinates. y y y x z projection x x t z s

5 Working with Curved Surfaces
When mapping texture onto a curved surface, it is useful to represent the surface in parametric form: We can relate the texture coordinates to the image coordinates as follows: u = as + bt + c v = ds + et + f where ae does not equal bd

6 Mapping onto a rectangle
Mapping onto a rectangle is like a simple coordinate switch: (smax, tmax) t v (umax, vmax) s u (smin, tmin) (umin, vmin)

7 Mapping a square onto a cylinder
Define texture on a unit square: Parametric representation of cylinder: Map with u = s and v = t: t v s u p(x, y, z)

8 Problems in mapping 2D to 3D
For some 3D surfaces, it is hard to map from 2D to 3D. For example, imagine trying to wrap a piece of paper around a soccer ball! Mapping a rectangular texture onto a sphere is difficult to do without generating distortions in the texture.

9 Methods for Mapping 2D to 3D
One solution is to unfold the 3D object into a 2D surface: Unfolded cube: Map the 2D texture onto the unfolded object, then fold it again. This does not work as well for a sphere. Flattening a sphere leads to distortions (e.g. world maps).

10 Mapping to an intermediate surface
Another solution is to map the texture onto an intermediate surface (a sphere, a box or a cylinder) and then map from there onto the 3D object. Ways of mapping: Normals of intermediate object to final object Normals of final object to intermediate object Mapping from center of final object Different choices give different results.

11 Aliasing Because we are mapping discrete points (texels) onto discrete points (pixels) there can be problems if the relative sizes and resolutions do not match. Aliasing occurs in repeated textures, when sampling from the texture skips over pieces of the texture. t v Disappearing Stripes s u Aliasing can cause texture elements to disappear and can also cause moire patterns. Area averaging: One way to deal with aliasing is to assign the average of the texel with the nearest neighboring texels to the point on the surface. This limits the moire patterns, but does not help with the disappearing stripes (we just see gray instead of white).

12 Scaling the texture Problems arise when the texture scale does not match the image scale. We may have several texels mapping to a single pixel (or vice versa). t v s u Solutions: Use averaging: Use the nearest texel value; Or Use Mipmapping Mipmapping works by creating a set of texture arrays for different resolutions. E.g. 64 x 64, 32 x 32, 16 x 16, etc. OpenGL then chooses the appropriate mipmap for a given object. The one with the closest matching resolution will be used.


Download ppt "Graphics, Fall 2017 Lecture 24: Texture Mapping"

Similar presentations


Ads by Google