Classic mapping technique

advertisement
Classic mapping technique
7.1 Introduction
7.2 Two-dimensional texture maps to polygon mesh
objects
7.3 Two-dimensional texture domain to bi-cubic
parametric patch objects
7.4 Bump mapping
7.5 Environment or reflection mapping
7.6 Three-dimensional texture domain techniques
7.7 Comparative examples
7.1 Introduction

The mapping technique


Texture mapping


Techniques which store information in a 2D
domain which is used during rendering to
simulate textures.
The mainstream application
Reflection mapping

Simulate ray tracing
7.1 Introduction

Environment mapping


Add pseudo-realism to shiny animated objects by
causing their surrounding environment to be
reflected in them.
Color mapping



Texture - does not mean controlling the microfacets of the objects
controlling the value of the diffuse coefficients
Shading changes as a function of the texture
maps.
7.1 Introduction

Three origins to the difficulties



How can we physically derive a texture value at a
surface point if the surface does not exits.
How to map a 2D texture onto a surface that is
approximated by a polygon mesh.
Aliasing problem
Possible ways to modulate a computer
graphics model with a texture map

Color


Specular color (environment mapping)


Applies perturbation to the surface normal according to the
corresponding value in the map.
Displacement mapping


Special case of ray tracing
Normal vector perturbation (bump mapping)


Modulate the diffuse reflection coefficients in the local reflection
model.
Uses a height field to perturb a surface point along the direction of its
surface normal.
Transparency

Used to control the opacity of a transparent object
Ways to perform texture mapping

Choice depend on




Time constraints
Quality of the image required
We will restrict the discussion to 2D texture maps.
(Heckberts 1986)
2D Texture mapping

2D-to-2D transform


2D texture
object surface
screen space
can be viewed as an image warping operation
Ways to perform texture mapping

Forward mapping

Two stages process

2D texture space -> 3D object space


3D object space 2D screen space


Parametrisation

Associates all points in texture space with points on the object
surface
Projective transform
Inverse mapping

For each pixel we find its corresponding pre-image in
texture space.
Two ways of viewing the process of
2D texture mapping
(a) Forward mapping (b) Inverse mapping
7.2 Two-dimensional texture maps to
polygon mesh objects
7.2.1 Inverse mapping by bi-linear interpolation
7.2.2 Inverse mapping by using an intermediate
surface
7.2.3 Practical texture mapping
7.2.1 Inverse mapping by bi-linear
interpolation

Inverse mapping

Consider a single transformation for 2D screen space
(x,y) to 2D texture space (u,v).

An image warping, can be modelled as a rational linear
projective transform:

We can write this in homogeneous coordinates as :
The inverse transform

If we have the association for the four vertices of a
quadrilateral we can find the nine coefficients
(a,b,c,d,e,f,g,h,i)
Bi-linear interpolation in screen space

Assuming vertex coordinate/texture coordinate for all polygons we
consider each vertex to have homogeneous texture coordinates:
( u , v , q )
where : u  u  / q , v  v  / q , q  1 / z

Use normal bi-linear interpolation scheme within the polygon, using
homogeneous coordinates as vertices to give (u’,v’,q) for each pixel;
then the required texture coordinates are give by:
(u , v )  (u  / q , v  / q )
7.2.2 Inverse mapping by using an
intermediate surface



Used when there is no texture coordinate-vertex
coordinate correspondence.
It can be used as a preprocess to determine the
correspondence.
Two-part texture mapping:



To overcome the surface parametrisation problem
Introduced by Bier and Sloan (1986)
The intermediate surface must has an analytic
mapping function.
Two-stage forward mapping process

First stage : S mapping

2D texture space to 3D intermediate surface
T ( u , v )  T ( x i , y i , z i )

Second stage : O mapping

3D texture pattern onto object surface.
T ( x i , y i , z i )  O ( x w , y w , z w )
Two-stage forward mapping process
S mapping

Bier describes 4 intermediate surfaces





A plane at any orientation
The curved surface of a cylinder
The faces of a cube
The surface of a sphere
For example

Given a parametric definition of the curve surface of a cylinder as a set
of points (,h)


c , d are scaling factors
θ0 and h0 position the texture on the cylinder of radius r.
Four O mapping
Inverse mapping using the shrink wrap
method
Inverse mapping using the shrink wrap
method
Inverse mapping
Examples

Examples of mapping the same texture onto an object using different
intermediate surfaces
7.2.3 Practical texture mapping
7.2.3 Practical texture mapping

An example of a tank object texture being created from a photograph
of a tank
7.2.3 Practical texture mapping

Interactive texture mappingpainting in T (u,v) space
7.2.3 Practical texture mapping

Agglomerating part maps into a single texture map.
7.3 Two-dimensional texture domain to
bi-cubic parametric patch objects

The parametrization is trivial


T (s,t)
Catmull (1974)



P (u,v)
Subdivide patch in object space, and at the same time
subdivide corresponding texture in texture space.
Patch subdivision proceeds until it covers a single pixel
Cook (1987)

Object surfaces are subdivided into micro-polygons and
flat shaded with values from a corresponding subdivision
in texture space
7.3 Two-dimensional texture domain to
bi-cubic parametric patch objects

Example
7.4 Bump mapping
7.4.1 A multi-pass technique for bump mapping
7.4.2 A pre-calculation technique for bump
mapping
7.4 Bump mapping



Developed by Blinn in 1978
An elegant device that enables a surface to
appear as if it were wrinkled or dimpled
without the need to model these depressions
geometrically.
The only problem

Silhouette edge that appears to pass through a
depression will not produce the expected crosssection
A one-dimensional example of the
stages involved in bump mapping
The surface and its normal


Assuming the surface is defined by a bivariate parametric
function P(u,v)
The surface normal on each point of the surface is then
defined as
N 

P
u

P
v
 Pu  Pv
Pu and Pv are the partial derivatives lying in the tangent plane to the
surface at point P
The displaced surface and it’s surface
normal

The new displaced surface P’(u,v)
P ( u , v )  P ( u , v )  B ( u , v ) N


Two-dimensional height field B(u,v) called bump map
The new surface normal on P’
N   P u  P v
The partial derivatives of P’ and the
new surface normal on P’

The partial derivatives of P’
P u  P u  B u N  B ( u , v ) N u
P v  P v  B v N  B ( u , v ) N v

If B is small we can ignore the final term so N’ become:
N   N  B uN  P v  B vP u  N
or
N   N  B uN  P v  B vN  P u
 N  ( B uA  B vB )
 N D

D is a vector lying in the tangent plane that pull N into the desired
orientation and is calculated from partial derivatives of the bump
map and the two vectors in the tangent plane.
Geometric interpretation of bump
mapping
7.4.1 A multi-pass technique for bump
mapping


McReynolds and Blythe (1997) define a multi-pass
technique.
They split the calculation into two components. The final
intensity value is proportional to N’.L
N  L  N  L  D  L


First component : the normal Gouraud component
Second component : found from the differential coefficient of
two image projections
A multi-pass technique for bump
mapping (cont.)

To do this it is necessary to transform the light vector into
tangent space at each vertex of the polygon. This space is
defined by N, B, T




N is the vertex normal
T is the direction of increasing u (or v) in the object space
coordiante system
B=NT
Normalised components of these vectors defines the matrix
that transforms point into tangent space
L TS
 Tx
 Bx

Nx
 0

Ty
By
Ny
0
Tz
Bz
Nz
0
0
0
0
1 
A multi-pass technique for bump
mapping (cont.)

Algorithm is as follows
7.4.2 A pre-calculation technique for
bump mapping


Tangent space can also be used to facilitate a pre-calculation
technique as proposed by Peercy et al. (1997)
It can be shown that the perturbed normal vector on tangent space
given by
N TS 
a, b, c
(a  b  c )
2
2
2 1/ 2
where
a   B u( B  P v)
b   ( B v P u  B u (T  P v ))
c  Pu  Pv
Example for bump mapping

A bump mapped object with the bump map
Example for bump mapping

A bump mapped object from a procedurally
generated height field.
Example for bump mapping

Combining bump and color mapping

The bump and color map
7.5 Environment or reflection mapping



7.5.1 Cubic mapping
7.5.2 Sphere mapping
7.5.3 Environment mapping : comparative
points
7.5 Environment or reflection mapping

Originally called reflection mapping





Suggested by Blinn (1977)
Consolidated into mainline rendering techniques in an
important paper in 1986 by Greene
Used to approximate the quality of a ray-tracer for
specular reflections
It is a classic partial offline or pre-calculation
technique
V Rv
M(Rv)
7.5 Environment or reflection mapping
7.5 Environment or reflection mapping

Example
Disadvantages




Correct only when the object becomes small
with respect to the environment that contains
it.
An object can only reflects the environment –
not itself.
A separate map is require for each object.
A new map is required whenever the view
point changes
Environment mapping VS. ray tracing
Three methods for environment
mapping



Cubic mapping
Latitude-longitude mapping
sphere mapping
7.5.1 Cubic mapping
7.5.1 Cubic mapping

A problem of a cubic map is
that if we are considering a
reflection beam formed by
pixel corners, or equivalently
by reflected view vectors at a
polygon vertex , the beam can
index into more than one map.
Cubic environment map convention
7.5.2 Sphere mapping

Latitude-longitude projection



Blinn and Newell(1976)
Rv
T (u,v)
Main problem : singularities at the poles

As Rvz
+1,-1 both Rvx and Rvy
become ill-defined
0 and Rvy/Rvx
7.5.2 Sphere mapping

Haberli and Segal (1993) and Miller et al. (1998)
To generate the map

To index into the map

Constructing a spherical map
7.5.3 Environment mapping :
comparative points


Sphere mapping requires only one map, while
cubic mapping needs six maps.
Both type of sphere mapping suffer more
from non-uniform sampling than cubic
mapping.
Sampling the surface of a sphere
7.6 Three-dimensional texture
techniques
7.6.1 Three-dimensional noise
7.6.2 Simulating turbulence
7.6.3 Three-dimensional texture and animation
7.6.4 Three-dimensional light maps
7.6 Three-dimensional texture
techniques

Difficulties associated with mapping a 2D
texture onto the surface of a 3D object. The
reasons for this are :


Large variations in the compression of texture
Textural continuity across surface elements
Mapping

How to map object surfaces to texture space

3D to 3D mapping is straightforward, the
problems in 2D texture mapping is eliminated

Texture coordinate assignment can be
simple as straight mapping, u=x,v=y,w=z

(u,v,w) is a coordinate in the texture field.
Presentation

How to present the texture

layers of 2D iso-surfaces



Limited resolution and take up vast memory
Easily acquired through 3D layered scanning
procedural texture




A method that define procedurally a texture field in object space.
save storage space
Limited use
The color of the object determined by the intersection of its
surface with the texture field Solid Texture (Perlin 1985, Peachey
1985)
7.6.1 Three-dimensional noise



It is a popular class of procedural texturing
technique
It uses a 3D noise function as a basic
modeling primitive
It can be used to produce a surprising variety
of realistic natural-looking texture effects
Algorithm generation of solid noise




Perlin (1985) was the first to suggest this
application of noise.
Define a noise function noise()
It is called model directed synthesis
Evaluate the function only at points of interest
Noise function properties

Ideally, the function should posses the
following three properties



Statistical invariance under rotation.
Statistical invariance under translation.
A narrow bandpass limit in frequency


The first two conditions ensures that no matter how
we move or orientate the noise function in space its
general appearance remains the same.
The third condition enables us to sample the noise
function without aliasing
Perlin’s method of generating noise


Define an integer lattice situated at location (i,j,k)
Associate a random number with each point of the
lattice

The association can be done in two ways



A look-up table
Via a hashing function
The value of the noise function at a point in space

For the points on the lattice


The noise value is the associated random number
For other points not on the lattice

The noise value can be obtained by linear interpolation from the
nearby lattice points
Problems with Perlin’s method

The function will tends to exhibit directional
coherence

Can be ameliorated by using cubic interpolation




Expensive
The coherence still tend to be visible
Alternative methods
Lewis (1989)
7.6.2 Simulating turbulence

The most versatile of its applications is the use of the
so-called turbulence function


Takes a position x and returns a turbulent scalar value
The 1D version defined as
k

turbulence (x)=  abs (
i0

1
2

2
i
)
The summation is truncated at k which is the smallest integer
satisfying


i
noise ( 2 x )
k 1
< the size of a pixel
Exhibits self-similarity
Power spectrum obeys a 1/f power law
Two stages in the process of simulating
turbulence


Representation of the basic, first order,
structural features of a texture through some
basic functional form.
Addition of 2nd and higher order detail by
using turbulence to perturb the parameters of
the function.
Example : the marble

The basic function form


marble(x) = marble_color(sin(x))
Adding turbulence

marble(x)=marble_color(sin(x+turbulence(x))
Example : the marble
Remark

The use of turbulence function need not be
restricted to modulated just the color of an
object

Surface bumps



Oppenheimer(1986) Turbulates a sawtooth function to
bump map the ridges of bark on the tree.
Transparency
Density
7.6.3 Three-dimensional texture and
animation

Define turbulence function over time as well
as space simply by adding an extra dimension
representing time to the noise integer lattice.


Lattice point indices (i,j,k,l)
Noise function: noise (x,t)
Example : simulate fire

Basic form: the flame shape


First define a flame region in the xy plane
Flame color in this region is given by
flame ( x )  (1  y / h ) flame _ colour ( abs ( x / b )  turbulence ( x , t ))
Example : simulate fire

The turbulated form

Flame (x,t) = (1-y/h) flame_colour(abs(x/b)+burbulence(x,t))
Convection

flame(x,t) =

(1-y/h) flame_color(abs(x/b)+turbulence(x+(0,ty,0),t))
7.6.4 Three-dimensional light maps



A method of caching the reflected light at
every point in the scene.
Store reflected light at a point in a 3D
structure that represents object space
The practical restriction is the cost of vast
memory resources.
7.7 Comparative examples
7.7.1 Figure 7.23
7.7.2 Figure 7.24
7.7.3 Figure 7.25
7.7.1 Figure 7.23
7.7.2 Figure 7.24
7.7.2 Figure 7.24

Shadow and environment map
7.7.3 Figure 7.25
Download