Title: Texture Mapping
1Texture Mapping
- (Some Images from Rosalee Wolff)
2Texture Mapping
- Problem with shading models
- -they assume that a diffuse surface has uniform
reflectance - This is okay for walls or pool balls, but not
most objects - We could add geometric complexity
- - BAD! Too time consuming
- Alternative Texture mapping
- - Developed by Catmull (1974), Blinn and Newell
(1976), and others
3Texture Mapping
- Goal add visual detail without adding geometric
detail - 8 polygons 8 polygons
4Typical Textures
5Replicating Textures
6Replicating Textures
7Textures
Any image can be used as a texture map
8Texture Mapping
- There are both 2D and 3D versions of texture
mapping - 2D wallpaper a 2D image onto an object
- 3D carve a 3D object out of a block
92D Texture Mapping
- Given a 2D texture (image) and a 3D object, map
the texture onto the object. - Where does each point on the object map into the
texture?
10Texture Map Shapes
- Planar Map
- Simply remove one of the objects coordinates
(project onto that coordinate plane)
11Planar Map
- This has the unwanted side effect of keeping the
texture constant in one direction. - E.g., projecting along Z
12Planar Map
- Projecting along X and Y respectively
13Cylindrical Map
- Instead of a planar map, we could use a
cylindrical map - (x,y,z) is converted to (r, theta, height).
- For texture mapping, theta is converted into a
u-coordinate and height is converted into a
v-coordinate. - This wraps the two-
- dimensional texture
- map around the object.
14Cylindrical Map
- At minimum and maximum extents of the cylinder,
the texture gets pinched together. - E.g., a cylindrical map parallel to Z
15Cylindrical Map
- Similarly if the map is parallel to X or Y
16Spherical Map
- Convert from (x, y, z) to spherical coordinates.
- Latitude is converted to a u-coordinate,
longitude is converted to a v-coordinate.
17Spherical Map
- This still has the effect of pinching the texture
at the poles, but differently than using a
cylindrical map.
18Spherical Map
- With the poles in the X and Y directions
19Box Map
- We can use a collection of planar maps to provide
better coverage than using a single planar map
20Box Map
- We project each plane onto its portion of the
object. - Use the objects normal to determine which
texture to use.
21Box Map
22Box Map
- Using a different set of textures
23Box Map
24Texture Mapping Applet
25Map Entity
- To texture map, we take an (x, y, z) value from
the object and determine a (u, v) texture value. - How we determine what we use as the (x, y, z)
value is the map entity. - Can use various things
- a point on the object relative to the objects
bounding box - the surface normal at the point being rendered
- a vector running from the objects centroid
through the point - the reflection vector at the current point
26Map Entity
27Map Entity
- Using the same map shape, but different map
entity can give quite different results. - Planar Mapping
28Map Entity
29Map Entity
30Map Entity
31Texture Mapped Scene
http//daemonic.xeebra.com/raytracer/texture_mappi
ng.png
32Another Example
33The Texture Mapping Process
(inverse map)
(raytrace)
Pixel
Texture Map
Surface
34- Consider surface visible at current pixel.
- Find the patch on the surface that corresponds to
it. - Map screen coord of pixel corners back to object
- Find texels that map to the surface patch
- If multiple texels lie on patch combine them
- weighted avg supersampling with
postfiltering
35Mapping Parametric Surfaces
- Parametric surfaces are already parameterized by
(s, t). - Use the (s,t) parameters as the (u,v) texture
parameters
36The Utah Teapot
37Non-Parametric Surfaces
- If we assign values to the vertices in the range
(0,1), we can use the same texture mapping
approach
38Non-linear Mapping
- We can distort the texture by using a non-linear
mapping
39Triangles
- Given a triangle defined by three points (a, b,
c), how do we associate a texture color with a
point on the triangle?
c
?
b
a
40Computing the Point
- Given the (x,y) point in the triangle, how do we
transform that to a (u,v) point in the image? - Set up a non-orthogonal coordinate system with
origin a and basis vectors (b-a) and (c-a)
c
g2
c-a
g1
b
b-a
a
g0
b-1
b0
b1
41Barycentric coordinates
- Any point on the triangle can be defined by the
barycentric coordinate - p a b(b-a) g(c-a)
c
g2
p
c-a
g1
b
b-a
a
g0
b-1
b0
b1
42Barycentric coordinates
- Once we have computed the (b,g) barycentric
coordinate for the triangle, we can determine the
corresponding (u, v) point. - First, establish the (u, v) system
(0, 1)
(1, 1)
(0, 0)
(1, 0)
43Computing the (u, v) coordinate
- u(b, g) ua b(ub ua) g(uc ua)
- v(b, g) va b(vb va) g(vc va)
44Performing the transformation
- We can then compute the color for that point of
the triangle.
c
b
a
45Other Mapping Applications
- Color Mapping diffuse component of surface
(standard texture mapping) - Reflection Mapping specular component of surface
to simulate reflection (environment mapping) - Normal vector Mapping simulate 3D surface
structure (bump mapping) - Geometry Mapping raise/lower points to actually
modify surface (displacement mapping) - Transparency Mapping vary the transparency
across the object
46Reflection Mapping
- Also called Environment Mapping
- Idea
- surround the scene with an image
- for reflective surfaces, rather than ray tracing
them, simply see what part of the image would be
seen on the object - Used in Abyss, Terminator 2
47Reflection Mapping Example
From Ed Angel, Interactive Computer Graphics,
Addison-Wesley 2002
48Reflecting
N
V
R
49Reflection Mapping
- Usually done either with
- Sphere (or hemisphere)
- Cube
50Hemisphere Mapping
N
V
R
51Hemisphere Mapping
- Objects mapped onto the hemisphere will look the
same as the objects out in space - The hemisphere map is used as the texture map
52Cube Mapping
- Same idea as hemisphere mapping, but use a cube
instead - Simpler in some ways
- Have to deal with the corners and edges of the
cube
53Hemisphere Mapping
N
V
R
54Issues with Reflection Mapping
- Must assume that the environment is very far away
from the scene - No self reflections (concave objects dont work
correctly) - No reflections between objects
55Example
from http//www.inf.ufrgs.br/7Eoliveira/Cursos/C
MP513/CMP513_trabalhos.html
56Bump Mapping
- Texture mapping adds color detail to the object,
but the object still looks smooth - How do you make the object look rough?
- Solution 1 Could add more polygons
- Too time intensive
- Solution 2 Bump mapping
57Bump Mapping
- Idea
- If we use fake normals, we can trick the
renderer into thinking there are bumps on the
surface
Flat Plane
Real Bump
Fake Bump
58Sphere with Texture and Bump Maps
Bump Map
Sphere with Texture Map
59The Bump Map
- The bump map is defined as an array of
displacements B(u,v) - If P(u,v) specifies positions on a parametric
surface, the normal at the surface can be
calculated as - where and are partial derivatives
of the surface at point P lying in the tangent
plane
N
Pu
Pv
60Bump Mapping
- We can simulate bumps by adding small
perturbations to the surface positions along the
direction of the normal
61Bump Mapping
Original surface P
Bump map B
Bump map applied to surface giving P
62Bump Mapping
- Next we compute new normals for bump mapped
surface
63 64- To simplify, we approximate, using as the reason
that the bump should be significantly smaller
than the surface. Thus, we remove the last terms
of the equations, giving
65 66then
67- This gives
- This gives a normal perturbation that is
- independent of the position of the object
- independent of the orientation of the object
- i.e., a position on the object will always get
the same perturbation
68Bump Function
- Bump function can be
- Analytical expression
- Table lookup
- use linear interpolation to compute B
- use finite differences to approximate Bu and Bv
69Bump Mapping Examples
70Bump Mapping Examples
71Bump Mapping Examples
72Bump Mapping Examples
- from http//www.vis-sim.org/support/vp_websamples2
.shtml
73Horizon Mapping
- A technique to try to get shadow information from
a bump-mapped surface - For each point on the surface, the angle to the
horizon is computed and stored in a horizon map - Stored for a small number of directions (8 or 16
usually) - To compute lighting, the horizon map is
consulted, the height of the point being rendered
is determined, and the angle to the light is
computed - If the light angle is less than the horizon map
angle, the point is in shadow
74Horizon Mapping
- from http//www.soft.dk/directx-3d-demos.htm
75Displacement Mapping
- The actual geometry is altered in order to allow
for a more bumpy look - A displacement map is given, along with the
surface - The displacement map is applied to the surface,
and additional geometry is introduced where
needed - Gives a more realistic look, particularly at the
silhouette - Quite a bit more costly than the other techniques
76(No Transcript)
77Parallax Mapping
- Also termed view displacement mapping
- Texture coordinates are displaced as a function
of the view angle and the height at the point
being rendered - Gives similar effects as displacement mapping,
without the overhead of increased geometry
78Parallax Mapping
- Example of parallax mapping. The walls are
textures with parallax maps. Screenshot taken
from one of the base examples of the opensource
Irrlicht 3d engine.
79Parallax Mapping
80Comparison
Displacement mapping
Bump mapping
81Comparison
- from http//www.chromesphere.com/Tutorials/Vue6/Op
tics_Basics_Print.html
82Comparison
Bump Mapping
Horizon Mapping
Displacement Mapping
View Dependent Displacement Mapping