CSE4030

Introduction to

Dongguk University Jeong-Mo Hong Week 11

• Are you naked? – Texturing – How to clothe your virtual girl friend

2/28

3/28 Example

4/28 Objectives

• Introduce Mapping Methods – Texture Mapping – Environment Mapping –

• Consider basic strategies – Forward vs backward mapping – Point sampling vs area averaging

5/28 The Limits of Geometric Modeling

• Although graphics cards can render over 10 million polygons per second, that number is insufficient for many phenomena – Clouds – Grass – Terrain – Skin

6/28 Modeling an Orange

• Consider the problem of modeling an orange (the fruit) • Start with an orange-colored sphere – Too simple • Replace sphere with a more complex shape – Does not capture surface characteristics (small dimples) – Takes too many polygons to model all the dimples

7/28 Modeling an Orange (2)

• Take a picture of a real orange, scan it, and “paste” onto simple geometric model – This process is known as texture mapping • Still might not be sufficient because resulting surface will be smooth – Need to change local shape – Bump mapping

8/28 Three Types of Mapping

• Texture Mapping – Uses images to fill inside of polygons • Environment () – Uses a picture of the environment for texture maps – Allows simulation of highly specular surfaces • Bump mapping – Emulates altering vectors during the rendering process 9/28 Texture Mapping

geometric model texture mapped

10/28 Bump Mapping

• A sphere without bump mapping (left). • A bump map to be applied to the sphere (middle). • The sphere with the bump map applied (right) appears to have a mottled surface resembling an orange. • Bump maps achieve this effect by changing how an illuminated surface reacts to light without actually modifying the size or shape of the surface • http://en.wikipedia.org/wiki/Bump_mapping 12/28 Limit of Bump Mapping [1/2] Limit of Bump Mapping [2/2]

• Bump mapping is limited in that it does not actually modify the shape of the underlying object. • On the left, a mathematical function defining a bump map simulates a crumbling surface on a sphere, but the object's outline and shadow remain those of a perfect sphere. • On the right, the same function is used to modify the surface of a sphere by generating an isosurface. • This actually models a sphere with a bumpy surface with the result that both its outline and its shadow are rendered realistically. • http://en.wikipedia.org/wiki/Bump_mapping

• To calculate the Lambertian (diffuse) lighting of a surface, the unit vector from the point to the light source is dotted with the unit vector normal to that surface, and the result is the intensity of the light on that surface. • By using a 3-channel bitmap textured across the model, more detailed normal vector information can be encoded. • http://en.wikipedia.org/wiki/Normal_mapping

• Parallax mapping is implemented by displacing the texture coordinates at a point on the rendered polygon by a function of the view angle in tangent space (the angle relative to the surface normal) and the value of the height map at that point. • At steeper view-angles, the texture coordinates are displaced more, giving the illusion of depth due to parallax effects as the view changes. • http://en.wikipedia.org/wiki/Parallax_mapping

• Displacement mapping is an alternative computer graphics technique to cause an effect where the actual geometric position of points over the textured surface are displaced. • http://en.wikipedia.org/wiki/Displacement_mapping Multi-Texturing

• Rendering a wall lit by a spotlight using multitexturing. • Here we combine the two textures by multiplying the corresponding texels together. • http://glasnost.itcarlow.ie/~powerk/GeneralGraphicsNotes/Theory/ma ppinglighting.htm Light Map Environment Mapping

• specular reflection working with environment mapping • http://graphics.ucsd.edu/courses/rendering/2007/chu/

11/28 Multi-Texturing on Terrains

• Without detail textures (left) • With detail textures (right) • http://www.cs.auckland.ac.nz/~jvan006/multitex/ multitex.html Where does mapping take place?

• Mapping techniques are implemented at the end of the rendering pipeline – Very efficient because few polygons make it past the clipper

13/28 CSE4030

Break and Q&A

14/28 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

15/28 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

16/28 Texture Mapping

parametric coordinates

texture coordinates window coordinates world coordinates

17/28 Mapping Functions • Basic problem is how to find the maps • Consider mapping from texture coordinates to a point a surface • Appear to need three functions (x,y,z) x = x(s,t) y = y(s,t) t z = z(s,t) s • But we really want to go the other way

18/28 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 = s(x,y,z) t = t(x,y,z) • Such functions are difficult to find in general 19/28 Two-part mapping

• One solution to the mapping problem is to first map the texture to a simple intermediate surface • Example: map to cylinder

20/28 Cylindrical Mapping parametric cylinder x = r cos 2p u y = r sin 2pu z = v/h maps rectangle in u,v space to cylinder of radius r and height h in world coordinates s = u t = v

maps from texture space

21/28 Spherical Map

We can use a parametric sphere

x = r cos 2pu y = r sin 2pu cos 2pv z = r sin 2pu sin 2pv

in a similar manner to the cylinder but have to decide where to put the distortion

Spheres are used in environmental maps

22/28 Box Mapping

• Easy to use with simple orthographic projection

• Also used in environment maps

23/28 Second Mapping

• Map from intermediate object to actual object – Normals from intermediate to actual – Normals from actual to intermediate – Vectors from center of intermediate actual intermediate

24/28 Aliasing

• Point sampling of the texture can lead to aliasing errors

miss blue stripes point samples in u,v (or x,y,z) space

point samples in texture space

25/28 Area Averaging

A better but slower option is to use area averaging

pixel preimage

Note that preimage of pixel is curved

26/28 Lab 11

• How to clothe your virtual girl friend

27/28