Classic mapping technique 7 1 Introduction 7 2

  • Slides: 79
Download presentation
Classic mapping technique 7. 1 Introduction 7. 2 Two-dimensional texture maps to polygon mesh

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 o The mapping technique n o Texture mapping n o Techniques

7. 1 Introduction o The mapping technique n o Texture mapping n o Techniques which store information in a 2 D domain which is used during rendering to simulate textures. The mainstream application Reflection mapping n Simulate ray tracing

7. 1 Introduction o Environment mapping n o Add pseudo-realism to shiny animated objects

7. 1 Introduction o Environment mapping n o Add pseudo-realism to shiny animated objects by causing their surrounding environment to be reflected in them. Color mapping n n n 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 o Three origins to the difficulties n n n How can

7. 1 Introduction o Three origins to the difficulties n n n How can we physically derive a texture value at a surface point if the surface does not exits. How to map a 2 D 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 o Color

Possible ways to modulate a computer graphics model with a texture map o Color n o Specular color (environment mapping) n o Applies perturbation to the surface normal according to the corresponding value in the map. Displacement mapping n o Special case of ray tracing Normal vector perturbation (bump mapping) n o 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 n Used to control the opacity of a transparent object

Ways to perform texture mapping o Choice depend on n n o o Time

Ways to perform texture mapping o Choice depend on n n o o Time constraints Quality of the image required We will restrict the discussion to 2 D texture maps. (Heckberts 1986) 2 D Texture mapping n 2 D-to-2 D transform o n 2 D texture object surface screen space can be viewed as an image warping operation

Ways to perform texture mapping o Forward mapping n Two stages process o 2

Ways to perform texture mapping o Forward mapping n Two stages process o 2 D texture space -> 3 D object space n o Parametrisation o Associates all points in texture space with points on the object surface 2 D screen space Projective transform Inverse mapping n For each pixel we find its corresponding pre-image in texture space.

Two ways of viewing the process of 2 D texture mapping (a) Forward mapping

Two ways of viewing the process of 2 D texture mapping (a) Forward mapping (b) Inverse mapping

7. 2 Two-dimensional texture maps to polygon mesh objects 7. 2. 1 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 o Inverse mapping n Consider a

7. 2. 1 Inverse mapping by bi-linear interpolation o Inverse mapping n Consider a single transformation for 2 D screen space (x, y) to 2 D texture space (u, v). o An image warping, can be modelled as a rational linear projective transform: o We can write this in homogeneous coordinates as :

The inverse transform o If we have the association for the four vertices of

The inverse transform o 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 o Assuming vertex coordinate/texture coordinate for all polygons we

Bi-linear interpolation in screen space o Assuming vertex coordinate/texture coordinate for all polygons we consider each vertex to have homogeneous texture coordinates: o 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:

7. 2. 2 Inverse mapping by using an intermediate surface o o o Used

7. 2. 2 Inverse mapping by using an intermediate surface o o o 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: n n o 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 o First stage : S mapping n o 2 D

Two-stage forward mapping process o First stage : S mapping n o 2 D texture space to 3 D intermediate surface Second stage : O mapping n 3 D texture pattern onto object surface.

Two-stage forward mapping process

Two-stage forward mapping process

S mapping o Bier describes 4 intermediate surfaces n n o A plane at

S mapping o Bier describes 4 intermediate surfaces n n o A plane at any orientation The curved surface of a cylinder The faces of a cube The surface of a sphere For example n Given a parametric definition of the curve surface of a cylinder as a set of points ( , h) o o c , d are scaling factors θ 0 and h 0 position the texture on the cylinder of radius r.

Four O mapping

Four O mapping

Inverse mapping using the shrink wrap method

Inverse mapping using the shrink wrap method

Inverse mapping using the shrink wrap method Inverse mapping

Inverse mapping using the shrink wrap method Inverse mapping

Examples of mapping the same texture onto an object using different intermediate surfaces

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

7. 2. 3 Practical texture mapping o An example of a tank object texture

7. 2. 3 Practical texture mapping o An example of a tank object texture being created from a photograph of a tank

7. 2. 3 Practical texture mapping o Interactive texture mappingpainting in T (u, v)

7. 2. 3 Practical texture mapping o Interactive texture mappingpainting in T (u, v) space

7. 2. 3 Practical texture mapping o Agglomerating part maps into a single texture

7. 2. 3 Practical texture mapping o Agglomerating part maps into a single texture map.

7. 3 Two-dimensional texture domain to bi-cubic parametric patch objects o The parametrization is

7. 3 Two-dimensional texture domain to bi-cubic parametric patch objects o The parametrization is trivial n o T (s, t) Catmull (1974) n n o 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) n 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 o Example

7. 3 Two-dimensional texture domain to bi-cubic parametric patch objects o Example

7. 4 Bump mapping 7. 4. 1 A multi-pass technique for bump mapping 7.

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 o o o Developed by Blinn in 1978 An elegant

7. 4 Bump mapping o o o 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 n 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

A one-dimensional example of the stages involved in bump mapping

The surface and its normal o o Assuming the surface is defined by a

The surface and its normal o o 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 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 o The new displaced surface P’(u, v)

The displaced surface and it’s surface normal o The new displaced surface P’(u, v) n o Two-dimensional height field B(u, v) called bump map The new surface normal on P’

The partial derivatives of P’ and the new surface normal on P’ o The

The partial derivatives of P’ and the new surface normal on P’ o The partial derivatives of P’ o If B is small we can ignore the final term so N’ become: n 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

Geometric interpretation of bump mapping

7. 4. 1 A multi-pass technique for bump mapping o o Mc. Reynolds and

7. 4. 1 A multi-pass technique for bump mapping o o Mc. Reynolds 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 n 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. ) o To do this it is

A multi-pass technique for bump mapping (cont. ) o 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 n n o 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

A multi-pass technique for bump mapping (cont. ) o Algorithm is as follows

A multi-pass technique for bump mapping (cont. ) o Algorithm is as follows

7. 4. 2 A pre-calculation technique for bump mapping o o Tangent space can

7. 4. 2 A pre-calculation technique for bump mapping o o 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

Example for bump mapping o A bump mapped object with the bump map

Example for bump mapping o A bump mapped object with the bump map

Example for bump mapping o A bump mapped object from a procedurally generated height

Example for bump mapping o A bump mapped object from a procedurally generated height field.

Example for bump mapping o Combining bump and color mapping n The bump and

Example for bump mapping o Combining bump and color mapping n The bump and color map

7. 5 Environment or reflection mapping o o o 7. 5. 1 Cubic mapping

7. 5 Environment or reflection mapping o o o 7. 5. 1 Cubic mapping 7. 5. 2 Sphere mapping 7. 5. 3 Environment mapping : comparative points

7. 5 Environment or reflection mapping o Originally called reflection mapping n n o

7. 5 Environment or reflection mapping o Originally called reflection mapping n n o o o 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

7. 5 Environment or reflection mapping o Example

7. 5 Environment or reflection mapping o Example

Disadvantages o o Correct only when the object becomes small with respect to the

Disadvantages o o 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

Environment mapping VS. ray tracing

Three methods for environment mapping o o o Cubic mapping Latitude-longitude mapping sphere mapping

Three methods for environment mapping o o o Cubic mapping Latitude-longitude mapping sphere mapping

7. 5. 1 Cubic mapping

7. 5. 1 Cubic mapping

7. 5. 1 Cubic mapping o A problem of a cubic map is that

7. 5. 1 Cubic mapping o 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

Cubic environment map convention

7. 5. 2 Sphere mapping o Latitude-longitude projection n n o Blinn and Newell(1976)

7. 5. 2 Sphere mapping o Latitude-longitude projection n n o Blinn and Newell(1976) Rv T (u, v) Main problem : singularities at the poles n As Rvz +1, -1 both Rvx and Rvy become ill-defined 0 and Rvy/Rvx

7. 5. 2 Sphere mapping o Haberli and Segal (1993) and Miller et al.

7. 5. 2 Sphere mapping o Haberli and Segal (1993) and Miller et al. (1998) To generate the map o To index into the map o

Constructing a spherical map

Constructing a spherical map

7. 5. 3 Environment mapping : comparative points o o Sphere mapping requires only

7. 5. 3 Environment mapping : comparative points o o 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

Sampling the surface of a sphere

7. 6 Three-dimensional texture techniques 7. 6. 1 Three-dimensional noise 7. 6. 2 Simulating

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 o Difficulties associated with mapping a 2 D texture

7. 6 Three-dimensional texture techniques o Difficulties associated with mapping a 2 D texture onto the surface of a 3 D object. The reasons for this are : n n Large variations in the compression of texture Textural continuity across surface elements

Mapping o How to map object surfaces to texture space n 3 D to

Mapping o How to map object surfaces to texture space n 3 D to 3 D mapping is straightforward, the problems in 2 D texture mapping is eliminated n Texture coordinate assignment can be simple as straight mapping, u=x, v=y, w=z o (u, v, w) is a coordinate in the texture field.

Presentation o How to present the texture n layers of 2 D iso-surfaces o

Presentation o How to present the texture n layers of 2 D iso-surfaces o o n Limited resolution and take up vast memory Easily acquired through 3 D layered scanning procedural texture o o 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 o o o It is a popular class of

7. 6. 1 Three-dimensional noise o o o It is a popular class of procedural texturing technique It uses a 3 D 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 o o Perlin (1985) was the first to suggest

Algorithm generation of solid noise o o 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 o Ideally, the function should posses the following three properties n

Noise function properties o Ideally, the function should posses the following three properties n n n Statistical invariance under rotation. Statistical invariance under translation. A narrow bandpass limit in frequency o o 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 o o Define an integer lattice situated at location

Perlin’s method of generating noise o o Define an integer lattice situated at location (i, j, k) Associate a random number with each point of the lattice n The association can be done in two ways o o n A look-up table Via a hashing function The value of the noise function at a point in space o For the points on the lattice n o The noise value is the associated random number For other points not on the lattice n The noise value can be obtained by linear interpolation from the nearby lattice points

Problems with Perlin’s method o The function will tends to exhibit directional coherence n

Problems with Perlin’s method o The function will tends to exhibit directional coherence n Can be ameliorated by using cubic interpolation o o n n Expensive The coherence still tend to be visible Alternative methods Lewis (1989)

7. 6. 2 Simulating turbulence o The most versatile of its applications is the

7. 6. 2 Simulating turbulence o The most versatile of its applications is the use of the so -called turbulence function n n Takes a position x and returns a turbulent scalar value The 1 D version defined as o turbulence (x)= o The summation is truncated at k which is the smallest integer satisfying n o o < the size of a pixel Exhibits self-similarity Power spectrum obeys a 1/f power law

Two stages in the process of simulating turbulence o o Representation of the basic,

Two stages in the process of simulating turbulence o o Representation of the basic, first order, structural features of a texture through some basic functional form. Addition of 2 nd and higher order detail by using turbulence to perturb the parameters of the function.

Example : the marble o The basic function form n o marble(x) = marble_color(sin(x))

Example : the marble o The basic function form n o marble(x) = marble_color(sin(x)) Adding turbulence n marble(x)=marble_color(sin(x+turbulence(x))

Example : the marble

Example : the marble

Remark o The use of turbulence function need not be restricted to modulated just

Remark o The use of turbulence function need not be restricted to modulated just the color of an object n Surface bumps o n n 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 o Define turbulence function over time as

7. 6. 3 Three-dimensional texture and animation o Define turbulence function over time as well as space simply by adding an extra dimension representing time to the noise integer lattice. n n Lattice point indices (i, j, k, l) Noise function: noise (x, t)

Example : simulate fire o Basic form: the flame shape n n First define

Example : simulate fire o Basic form: the flame shape n n First define a flame region in the xy plane Flame color in this region is given by

Example : simulate fire o The turbulated form n Flame (x, t) = (1

Example : simulate fire o The turbulated form n Flame (x, t) = (1 -y/h) flame_colour(abs(x/b)+burbulence(x, t))

Convection o flame(x, t) = n (1 -y/h) flame_color(abs(x/b)+turbulence(x+(0, t y, 0), t))

Convection o flame(x, t) = n (1 -y/h) flame_color(abs(x/b)+turbulence(x+(0, t y, 0), t))

7. 6. 4 Three-dimensional light maps o o o A method of caching the

7. 6. 4 Three-dimensional light maps o o o A method of caching the reflected light at every point in the scene. Store reflected light at a point in a 3 D 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. 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. 1 Figure 7. 23

7. 7. 2 Figure 7. 24

7. 7. 2 Figure 7. 24

7. 7. 2 Figure 7. 24 o Shadow and environment map

7. 7. 2 Figure 7. 24 o Shadow and environment map

7. 7. 3 Figure 7. 25

7. 7. 3 Figure 7. 25