Transcript Document

Texture = Arbitrary Illumination

Vary a surface property non-linearly


Rasterization does bi-linear interpolation
Examples of usage:

Paste a picture
picture of environment
 picture of scene


Modify surface normals

Create bumps and detail
Texture Mapping

Texture aka function of a surface


f (x,y,z) = some attribute value
Would like f to be arbitrary


Look-up table is a possible implementation



No continuity constraints
But not all x,y,z has the surface through it
Surface is only a 2-manifold
2D look-up table


But want to map every point on a surface to a 2D
space <u,v>
parameterization
Texture Mapping
v
u
Texture Coordinates
Pixel Texture Coordinates
Triangle
Pixel
Screen
Texture
Pixel Texture Lookup
Texel
Pixel
Texture-Minification
Texels
Pixels
These texels should also
contribute to the pixel
Mip-Mapping

Filter 2x2 texel blocks into one texel



Weighted average
Log(n) levels of an n xn texture map
Choose level closest to 1 texel/pixel

Pixel derivative
Derivative
Tex coord:
t0
t-1
t2
Pixels
Texels
t1
t3
t1 – t0 = (∆t xu, ∆t xv )
t2 – t0 = (∆tyu , ∆tyv)
∆t =
WxH texture =>
texel size = 1/W x 1/H
max (∆txu , ∆tyu), max(∆txu , ∆tyv)
Use divided difference: t1 – t-1
Anisotropic Filter
Texels
Pixels
Use Smallest minification
May read several texels
Texture Border

Extra texel needed for linear
interpolation
u=0
Other Texture Usage

Alpha Map


Transparent texture
Light Map


Diffused lighting independent of viewer
How do you generate it?






Texel to Object space reverse-mapping
Specular Map
Displacement Map
Bump Map
Environment Map
Point Sprites
Point Sprites

Draw points




E.g., as a k x k pixel square
Map a (small) texture on the point
Typically used with transparency
For example a cursor
Bump Mapping
Bump Mapping

Physically displace


Generate many
triangles
Simulate
Change the normal
 Normal affects lighting

N
Bump Mapping

Assume
‘Bump’ to the surface is small
 In the direction of the normal
 aka Height-map


Simulation:
P' = P + B(u,v) N
P'(u,v) = P(u,v) + B(u,v) N(u,v)
Bump Mapping


Tangent to the surface P(u,v) at a point (u,v):
Pu, Pv
N
The normal is then:


N(u,v) = Pu  Pv
P'(u,v) = P(u,v) + B(u,v) N


P'u = Pu + Bu N + B Nu  P'u = Pu + Bu N
P'v = Pv + Bv N + B Nv  P'v = Pv + Bv N
(if B is small)

P'u x P'v =
Pu  Pv + Bu(N  Pv) - Bv(N  Pu) + Bu Bv(N  N)
Bump Mapping
N'(u,v) =
Pu  Pv + Bu(N  Pv) - Bv(N  Pu) + Bu Bv(N  N)
= N + Bu(N  Pv) - Bv(N  Pu)
 N - BuPu – BvPv


if tangents are almost perpendicular
Note:
 Store Bu and Bv as
2-component texture
 Normalize N’
D
N’
N
Normal Mapping


Directly store the new normal per texel
From bump map:
Nx = (0, 1, Bu)
 Ny = (1, 0, Bv)
 N = Nx X Ny
 Remember to normalize


(and range compress)
Displacement Mapping

Modifies the surface position




Along surface normal, typically
Use if Bumps are large
Get silhouettes, shadows right
Much more expensive


Tessellate geometry
Some support in modern GPUs
Environment Mapping

Global Illumination:




Render the entire scene
Pick pixels in useful directions
Environment Map:






Reflected
ray
Assume high gloss
Find ideal reflected direction
Viewer
Look-up the value in that direction
Use one rendering
Eye at the center of the object


Environment Map
For each point on the surface
Where is the image plane?
Introduces distortions in the reflection
Good for small objects in a large room
Reflected
direction
Object
Example
Cube Mapping

Map onto surfaces of a cube (around the
object)



Find desired direction from a surface point
Cube map accessed by the direction



Axis-aligned often
One of the six faces of the cube intersects
The corresponding texture is looked up
For environment mapping:

Render scene from object-center onto cube face


Use, e.g, the six axis-aligned directions
Rendering may be pre-computed at high quality

E.g., 6 photos of a real environment
Cube Map Example