Texture Mapping -...

122
Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Transcript of Texture Mapping -...

Page 1: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Texture Mapping

Introduction to Computer Graphics

Torsten Möller

© Machiraju/Zhang/Möller/Fuhrmann

Page 2: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

2

Reading

• Angel - Chapter 7.4-7.10, 9.9 and 11.8

• Hughes, van Dam, et al: Chapter 20

(+17)

• Shirley+Marshner: Chapter 11

Page 3: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

3

Our aim today

• What is texture mapping / what types of

mappings do we have?

• Two-pass mapping

• Texture transformations

• Billboards, bump, environment, chrome,

light, and normal maps

• 3D texture mapping / volume rendering

• Hypertextures

Page 4: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

4

Texture Mapping

• (sophisticated) illumination models

– gave us “realistic” (physics-based) looking

surfaces

– not easy to model

– mathematically and computationally

challenging

• Phong illumination/shading

– easy to model

– relatively quick to compute

– only gives us dull surfaces

Page 5: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

5

Texture Mapping (2)

• surfaces “in the wild” are very complex

• cannot model all the fine variations

• we need to find ways to add surface

detail

• How?

Page 6: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Texture Mapping (3)

• solution - (it’s really a cheat!!)

Map surface detail

from a predefined

(easy to model)

table (“texture”) to

a simple polygon

• How?

© Machiraju/Zhang/Möller/Fuhrmann

6

Page 7: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Texture Mapping (4)

• Problem #1

– Fitting a square peg in

a round hole

– we deal with non-linear transformations

– which parts map where?

© Machiraju/Zhang/Möller/Fuhrmann

7

Page 8: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Texture Mapping (5)

• Problem #2

– Mapping from a pixel

to a “texel”

– aliasing is a huge problem!

© Machiraju/Zhang/Möller/Fuhrmann

8

Page 9: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

9

What is an image?

• How can I find an appropriate value for

an arbitrary (not necessarily integer)

index?

– How would I rotate an image 45 degrees?

– How would I translate it 0.5 pixels?

Page 10: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

10

What is a texture?

• Given the (texture/image index) (u,v),

want:

– F(u,v) ==> a continuous reconstruction

• = { R(u,v), G(u,v), B(u,v)}

• = {I(u,v) }

• = { index(u,v) }

• ={ alpha(u,v) }

• ={ normals(u,v) }

• = {surface_height(u,v) }

• = ...

Page 11: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

11

What is a texture? (2)

• Color

• specular ‘color’ (environment map)

• normal vector perturbation (bump map)

• displacement mapping

• transparency

• ...

Page 12: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

RGB Textures

• Places an image on the object

• “typical” texture mapping

© Machiraju/Zhang/Möller/Fuhrmann

12

Page 13: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

Dependend Textures

• Perform table look-ups after the texture

samples have been computed.

http://geomorph.sourceforge.net/13

Page 14: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Intensity Modulation Textures

• Multiply the objects color by that of the

texture.

© Machiraju/Zhang/Möller/Fuhrmann

14

Page 15: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Opacity Textures

• A binary mask,

redefines the

geometry by

setting parts of it

transparent

© Machiraju/Zhang/Möller/Fuhrmann

Page 16: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

Bump Mapping

• This modifies the surface normals.

16http://www.siggraph.org/education/materials/HyperGraph/hypergraph.htm

Page 17: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Displacement Mapping

• Modifies the surface position in the

direction of the surface normal.

http://www.chromesphere.com/Tutorials/Vue6/Optics-Basic.html

© Machiraju/Zhang/Möller/Fuhrmann

17

Page 18: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

18

Reflection Properties

• Kd, Ks

• BRDF’s

– Brushed Aluminum

– Tweed

– Non-isotropic or anisotropic surface micro

facets.

Page 19: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

19

Two-pass Mapping

• Idea by Bier and Sloan

• S: map from texture space to

intermediate space

• O: map from intermediate space to

object space

Page 20: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Two-pass Mapping (2)

• Map texture to intermediate (S map):

– Plane

– Cylinder

– Sphere

– Box

• Map object to same

(O map).

u

© Machiraju/Zhang/Möller/Fuhrmann

20

v

u-axis

Page 21: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

S map

zx

• Mapping to a 3D Plane

– Simple Affine transformation

• rotate

• scale

• translatey

v

u

© Machiraju/Zhang/Möller/Fuhrmann

21

Page 22: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

S map (2)

• Mapping to a Cylinder

– Rotate, translate and scale in the uv-plane

– u -> θ

– v -> z

– x = r cos(θ), y = r sin(θ)

v

u

© Machiraju/Zhang/Möller/Fuhrmann

22

Page 23: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

S map (3)

© Machiraju/Zhang/Möller/Fuhrmann

23

• Mapping to Sphere

– Impossible!!!!

– Severe distortion at the poles

– u -> θ

– v -> φ

– x = r sin(θ) cos(φ)

– y = r sin(θ) sin(φ)

– z = r cos(θ)

Page 24: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

S map (4)

• Mapping to a Cube

u

vcommon seam

© Machiraju/Zhang/Möller/Fuhrmann

24

Page 25: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

S map (5)

• Mapping to a Cube

© Machiraju/Zhang/Möller/Fuhrmann

25

Page 26: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

26

O map

• O mapping:

– reflected ray (environment map)

– object normal

– object centroid

– intermediate surface normal (ISN)

• that makes 16 combinations

• only 5 were found useful

Page 27: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

O map (2)

• Cylinder/ISN (shrinkwrap)

– Works well for solids of revolution

• Plane/ISN (projector)

– Works well for planar objects

• Box/ISN

• Sphere/Centroid

• Box/CentroidWorks well for roughly

spherical shapes

© Machiraju/Zhang/Möller/Fuhrmann

27

Page 28: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

O map (3)

• Plane/ISN

– Resembles a slide

projector

– Distortions on

surfaces

perpendicular to

the plane.

© Machiraju/Zhang/Möller/Fuhrmann

28

Page 29: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

O map (4)

• Cylinder/ISN

– Distortions on

horizontal planes

© Machiraju/Zhang/Möller/Fuhrmann

29

Page 30: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

O map (5)

• Sphere/ISN

– Small distortion

everywhere.

© Machiraju/Zhang/Möller/Fuhrmann

30

Page 31: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Texture Atlas

a texture atlas is a large image containing a

collection, or "atlas", of sub-images, each of which is

a texture map for some part of a geometric model.

© Machiraju/Zhang/Möller/Fuhrmann

31

Page 32: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Texture Atlas

© Machiraju/Zhang/Möller/Fuhrmann

32©Kevin Dobler, http://www.voidehawke.com/3dProfessional.html

Page 33: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

33

Our aim today

• What is texture mapping / what types of

mappings do we have?

• Two-pass mapping

• Texture transformations

– real-time vs. quality

• Billboards, bump, environment, chrome,

light, and normal maps

• 3D texture mapping / volume rendering

• Hypertextures

Page 34: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann32(c) Pascal Vuylsteker

Page 35: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

35

Texture Mapping - Practice I

• A lot of interaction is required to “get it

right” - modeler needs patience or a

good algorithm

• can’t really get distortion-free or size-

preserving mapspaint the texture on

the projected model(almost) do not

care about distortions!

• what else do we care about under the

topic “practical”?

Page 36: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

36

Texture Mapping - Practice II

• we need real-time performance

– “pre”-compute map of vertices (in the modeling

package; store these with the mesh data)

– quickly find an inverse mapping between internal

points of polygon and texels

– hardware support

• we need high quality (anti-aliasing)

– convolve with anti-aliasing filter

– “pre”-compute blurred (scaled-down) version

– “pre”-compute high-res (magnified) version

– hardware support

Page 37: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

37

Image space scan

• For each y

– For each x

• compute u(x,y) and v(x,y)

• copy texture(u,v) to image(x,y)

• Samples the warped texture at the

appropriate image pixels.

• inverse mapping

Page 38: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Z

Image space scan (2)

• Problems:

– Finding the inverse mapping

• Use one of the analytical mappings

• Bi-linear or triangle inverse mapping

– May miss parts of the texture map

hang/Möller 36(c) Pascal Vuylsteker

Page 39: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

©

Machiraju/Zhang/Möller/F

uhrmann

Texture space scan

• For each v

– For each u

• compute x(u,v) and y(u,v)

• copy texture(u,v) to image(x,y)

• Places each texture sample on the

mapped image pixel.

• Forward mapping

37

Page 40: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Mac

hiraju/Zhang/Möller

Texture space scan (2)

• Problems:

– May not fill image

– Forward mapping

needed

(c) Laurent Saboret, Pierre Alliez and Bruno38

vyLé

Page 41: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

39

Texture Mapping -

Real-Time

• Given: map of vertices

• Need: a 1-to-1 correspondence between

pixels of the screen projection of the

polygon to the texels in the texture

• main approaches:

– triangle mapping

– projective transformation

Page 42: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Triangle Interpolation

• The equation: f(x,y) = Ax+By+C defines a

linear function in 2D.

• Knowing the values of f() at three

locations gives us

enough information

to solve for A, B,

and C.

• We do this for both

components u(x,y) as well

as for v(x, y)

© Machiraju/Zhang/Möller/Fuhrmann

Page 43: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Triangle Interpolation (2)

• Ok for orthogonal

projections, but not for

the general case

• Need to take care of

perspective case

• We need to find two 3D

functions: u(x,y,z) and

v(x,y,z).

© Machiraju/Zhang/Möller/Fuhrmann

43

Page 44: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Triangle Interpolation (2)

© Machiraju/Zhang/Möller/Fuhrmann

44

Page 45: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Projective Transformation

• We actually map a square to a square

• we know there was a perspective

distortion - let’s set up a general model:

u

v

x

zP0

© Machiraju/Zhang/Möller/Fuhrmann

45

y

P1

ys

P2

P3

Page 46: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

• i can be set to one

• 8 equations, 8 unknowns!!

• Another way to look at it:

Projective Transformation (2)

© Machiraju/Zhang/Möller/Fuhrmann

46

Page 47: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Projective Transformation (3)

© Machiraju/Zhang/Möller/Fuhrmann

47

Affine texture mapping directly interpolates a texture coordinate uα between two endpoints u0 and u1:

Perspective correct mapping interpolates after dividing by depth z then uses its interpolated reciprocal to recover the correct coordinate:

https://en.wikipedia.org/wiki/Texture_mapping#Perspective_correctness

Page 48: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

48

• does NOT preserve equidistant points

• preserve lines in all orientations

• concatenation is projective again

• inverse mapping is a projective mapping

too

Projective Transformation (4)

Page 49: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Projective Transformation (5)

© Machiraju/Zhang/Möller/Fuhrmann 51

Page 50: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

50

Quality Considerations

• So far we just mapped one point

• results in bad aliasing (resampling

problems)

• we really need to integrate over polygon

• super-sampling is not such a good

solution (slow!)

• most popular - mipmaps

Page 51: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

51

Quality Considerations

ideal

no filter(point sampling)

box filter

Page 52: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

52

Quality Considerations

• Pixel area maps to “weird” (warped)

shape in texture space

• hence we need to:

– approximate this area

– convolve with a wide filter around the center

of this area

Page 53: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Quality Considerations

g/Möller 54© Machiraju/Zhan

Page 54: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

54

Quality considerations

• the area is typically approximated by a

rectangular region (found to be good

enough for most applications)

• filter is typically a box/averaging filter -

other possibilities

• how can we pre-compute this?

Page 55: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

55

How do we get F(u,v)?

• We are given a discrete set of values:

– F[i,j] for i=0,…,N, j=0,…,M

• Nearest neighbor:

– F(u,v) = F[ round(N*u), round(M*v) ]

• Linear Interpolation:

– i = floor(N*u), j = floor(M*v)

– interpolate from

F[i,j], F[i+1,j], F[i,j+1], F[i+1,j+1]

Page 56: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

56

How do we get F(u,v)? (2)

• Higher-order interpolation

–F(u,v) = ∑i∑j F[i,j] h(u,v)

– h(u,v) is called the reconstruction kernel

• Gaussian

• Sinc function

• splines

– Like linear interpolation, need to find

neighbors.

• Usually four to sixteen

Page 57: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

57

Quality considerations -

MipMap

• Downsample texture beforehand

• store down-sampled version as well

• find the right level of detail

• assumes symmetric square image region

(power of 2)

• problem - upsample?! (high-res)

Page 58: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Quality considerations -

MipMap

© Machiraju/Zhang/Möller/Fuhrmann

58

Page 59: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Quality considerations -

MipMap

© Machiraju/Zhang/Möller/Fuhrmann

59

Page 60: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

Quality considerations - SAT

• Summed area table:

• replace texture map with a sum of all

values below the texture entry

• problem - need to store huge numbers

• only works for rectangular aligned pixel

regions

61(c) nVIDIA

Page 61: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

62

Our aim today

• What is texture mapping / what types of

mappings do we have?

• Two-pass mapping

• Texture transformations

– real-time vs. quality

• Billboards, bump, environment, chrome,

light, and normal maps

• 3D texture mapping / volume rendering

• Hypertextures

Page 62: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

63

Texture Mapping

• Technicalities of the actual mapping

(correspond polygon points with entries

in a discrete table) are kind of “solved”

• next question - what are we going to do

with those values?

• Typical - just use them as our color

values (RGB)

• other methods ...

Page 63: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Billboards and Impostors

© Machiraju/Zhang/Möller/Fuhrmann

64

• BB s a simple plane that rotates always

perpendicular to the viewpoint

• combination of

color/opacity map

• Impostors contain more

complex geometry, e.g. for

trees

Page 64: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

65

Bump Mapping

• “real” texture - Many textures are the

result of small perturbations in the

surface geometry

• Modeling these changes would result in

an explosion in the number of geometric

primitives.

• Bump mapping attempts to alter the

lighting across a polygon to provide the

illusion of texture.

Page 65: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Bump Mapping (2)

• Consider the lighting for a modeled

surface.

© Machiraju/Zhang/Möller/Fuhrmann

Page 66: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Bump Mapping (3)

• We can model this as deviations from

some base surface.

• The question

is then how

these deviations

change the lighting.

N

© Machiraju/Zhang/Möller/Fuhrmann

Page 67: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Bump Mapping (4)

• Assumption: small deviations in the

normal direction to the surface.

• Where B is defined as a 2D function

parameterized over the surface:

B = f(u,v)

X = X + B N

© Machiraju/Zhang/Möller/Fuhrmann

Page 68: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

Bump Mapping (5)

• Step 1: Putting everything into the same

coordinate frame as B(u,v).

– x(u,v), y(u,v), z(u,v) – this is given for

parametric surfaces, but easy to derive for

other analytical surfaces.

– Or O(u,v) = [x(u,v), y(u,v), z(u,v)]T

Page 69: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Bump Mapping (6)

• Define the tangent plane to the surface at

a point (u,v) by using the two vectors Ou

and Ov.

• The normal is then given by:• N = Ou × Ov

NOv

Ou

© Machiraju/Zhang/Möller/Fuhrmann

Page 70: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

Bump Mapping (7)

• The new surface positions are then given

by:

• O’(u,v) = O(u,v) + B(u,v) N

• Where, N = N / |N|

• Differentiating leads to:≈ Ou + BuN

≈ Ov + BvN

• O’u = Ou + Bu N + B (N)u

• O’v = Ov + Bv N + B (N)v

If B is small.

Page 71: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Bump Mapping (8)

• This leads to a new normal:• N’(u,v) = Ou × Ov + Bu(N × Ov) - Bv(N × Ou)

+ Bu Bv(N × N)

= N + Bu(N × Ov) - Bv(N × Ou)

= N + D

N

DN’

Ov

Ou

© Machiraju/Zhang/Möller/Fuhrmann

Page 72: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

Bump Mapping (9)

• For efficiency, can store Bu and Bv in a 2-

component texture map.

• The cross products are geometry terms

only.

• N’ needs to be normalized after the

calculation and before lighting.

– This floating point square root and division

makes it difficult to embed into hardware.

Page 73: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Bump Mapping (10)

• Procedurally bump mapped object

© Machiraju/Zhang/Möller/Fuhrmann

74

Page 74: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Bump Mapping (11)

• bump mapped based on a simple image

cylindrical texture space used

© Machiraju/Zhang/Möller/Fuhrmann

75

Page 75: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

Bump Mapping (12)

• Bump mapping is often combined with texture

mapping. Here a bump map has been used to

(apparently) perturb the surface and a coincident

texture map to colour the 'bump objects'.

76

Page 76: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Bump Mapping (13)

• bump mapping and texture mapping on text

© Machiraju/Zhang/Möller/Fuhrmann

77

Page 77: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

78

Normal Map

• Pre-computation of modified normal

vector N‘

• Stored in texture (RGB)=(Nx, Ny, Nz)

• Illumination computation per pixel

– For example in fragment program

– Per-vertex light vector (toward light source)

is interpolated

Page 78: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Normal Map cont.

Color

Height

Normal Normal - z

Gra

die

nt

© Machiraju/Zhang/Möller/Fuhrmann

79

Normal - x Normal - y

Page 79: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Normal Map cont.

© Machiraju/Zhang/Möller/Fuhrmann

80

• Can be used for geometry simplification:

Page 80: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Normal Map cont.

© Machiraju/Zhang/Möller/Fuhrmann

81

(animation)

Page 81: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Environment Mapping

• Used to show the reflected colors in

shiny objects.

© Machiraju/Zhang/Möller/Fuhrmann

Page 82: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

82

Environment Mapping (2)

• Create six views from the shiny object’s

centroid.

• When scan-converting the object, index

into the appropriate view and pixel.

• Use reflection vector to index.

• Largest component of reflection vector

will determine the face.

Page 83: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Environment Mapping (3)

• Problems:

– Reflection is about object’s centroid.

– Okay for small objects and distant

reflections. N

N

© Machiraju/Zhang/Möller/Fuhrmann

Page 84: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Environment Mapping (4)

• Problems! – which one is ray-traced?

© Machiraju/Zhang/Möller/Fuhrmann

85

Page 85: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Environment Mapping (5)

• Problems:

© Machiraju/Zhang/Möller/Fuhrmann

86

Page 86: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

87

Chrome Mapping

• Cheap environment mapping

• Material is very glossy, hence perfect

reflections are not seen.

• Index into a pre-computed view

independent texture.

• Reflection vectors are still view

dependent.

Page 87: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

88

Chrome Mapping (2)

• Usually, we set it to a very blurred

landscape image.

– Brown or green on the bottom

– White and blue on the top.

– Normals facing up have a white/blue color

– Normals facing down on average have a

brownish color.

Page 88: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Chrome Mapping (3)

• Also useful for things like fire.

• The major point is that it is not important

what actually is shown in the reflection,

only that it is view dependent.

© Machiraju/Zhang/Möller/Fuhrmann

89

Page 89: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

90

Light Maps

• Precompute the light in the scene

• typically works only for view-independent

light (diffuse light)

• combine (texture-map) these light maps

onto the polygon

Page 90: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Light Map

ReflectanceQuake2 light map

• Combination:– Structural texture

– Light texture

• Light maps for diffuse reflection– Only Luminance channel

– Low resolution is sufficient

– Packing in “large” 2D texture

Irradiance

© Machiraju/Zhang/Möller/Fuhrmann

91Radiosity

Page 91: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Light Map cont.

• Combination with textured scene

© Machiraju/Zhang/Möller/Fuhrmann

92

Page 92: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Light Map cont.

• Example: moving spot light

© Machiraju/Zhang/Möller/Fuhrmann

93

Page 93: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

94

Our aim today

• What is texture mapping / what types of

mappings do we have?

• Two-pass mapping

• Texture transformations

– real-time vs. quality

• Billboards, bump, environment, chrome,

light, and normal maps

• 3D texture mapping / volume rendering

• Hypertextures

Page 94: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Participating Media

© Machiraju/Zhang/Möller/Fuhrmann 94

Page 95: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Participating Media

© Machiraju/Zhang/Möller/Fuhrmann 95

Page 96: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Participating Media

© Machiraju/Zhang/Möller/Fuhrmann 96

Page 97: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

3D Textures

• Representation on 3D domain

• Often used for volume

representation and rendering

– Texture = uniform grid

© Machiraju/Zhang/Möller/Fuhrmann

98

Page 98: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

©

Machiraju/Zhang/Möller/F

uhrmann

97

Direct Volume Rendering

• Emission-absorption model (Ch. 9 of PBRT book)

– No scattering

• Ray casting (ray marching without scattering)

– Image-space approach

• Possible on modern GPUs

– Fragment loop for traversal along ray

– Data stored in 3D texture, accessed by 3D texture

lookupIntegration segment (along eye ray)

Page 99: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

©

Machiraju/Zhang/Möller/Fu

hrmann

98

Direct Volume Rendering:

Texture Slicing• Data stored in 3D texture

• Object space approach with slices (= proxy geometry)

• Fast method that does not need programmable GPUs

Slices parallel to image plane

Textured slices

Final image

Texturing (trilinear interpolation)

Compositing(alpha blending)

Page 100: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

99

Solid Textures

• Problems of 2D textures– Only on surface (no internal, volumetric structure)

– Substantial texture deformation for strongly curved surfaces

– Texture coordinates difficult for complex objects / topology

• Solid textures– 3D textures for surface objects

– Cut a curved surface out of a volumetric texture block

– Example: wood, marble

• Disadvantages– Large memory consumption

Page 101: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Procedural Textures

• 3D textures based on noise and

mathematical modeling

• analogous to sculpting or carving

© Machiraju/Zhang/Möller/Fuhrmann

100

Page 102: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Solid Textures: Examples

© Machiraju/Zhang/Möller/Fuhrmann

103

Page 103: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

104

Our aim today

• What is texture mapping / what types of

mappings do we have?

• Two-pass mapping

• Texture transformations

– real-time vs. quality

• Billboards, bump, environment, chrome,

light, and normal maps

• 3D texture mapping / volume rendering

• Hypertextures

Page 104: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

©

Machiraju/Zhang/Möller/Fuhrmann

103

Noise and Turbulence

?• How to model texture for natural phenomena

– Physical simulation: time-consuming

– Instead: stochastic modeling by noise

• 2D and 3D textures

• Compact description of phenomena

– Typically only a few parameters

Page 105: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

104

Noise

• Natural objects are subject to stochastic variations– On different length scales

– With spatial coherence

• Goal: stochastic structures, not just white noise

• Requirements:– Spatial correlation (important for changing viewpoint)

– Reproducibility

– Controlled frequency behavior

– Band-limited (to avoid aliasing)

– No (visible) periodicity

– Rotation and translation invariant

– Restricted range of values (for mapping to colors, etc.)

Page 106: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann 105

Noise cont.

• Basis for stochastic modeling: noise function according

to Perlin[Ken Perlin, An image synthesizer, Computer Graphics (ACM SIGGRAPH 85), (3)19:287-296, 1985]

• Starting point: white noise (pseudo random numbers)

• Two kinds of Perlin noise:

– Lattice value noise

– Gradient noise

Page 107: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Perlin Lattice Value Noise

• Random number on lattice

• In-between: interpolation (higher-order)

– Leads to spatial correlation

– Band-limited

• Length scale is important

• Actual implementation:1D lattice with random numbers

and hash function

Index(ix,iy,iz) =

Permut(ix + Permut(iy + Permut(iz)))

– Avoids repeating patterns

© Machiraju/Zhang/Möller/Fuhrmann

108

Page 108: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Perlin Lattice Value Noise cont.

• Smooth across

small intervals

1.00

0.75

0.50

0.25

0

-0.25

-0.50

-0.75

-1.000 7.5 15 22.5 30

0.8

0.6

0.4

0.2

0

-0.2

-0.4

-0.6

-0.80 1.25 2.5 3.75 5

25 points

© Machiraju/Zhang/Möller/Fuhrmann

109

5 points

Page 109: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Perlin Lattice Value Noise cont.

64x64 lattice

© Machiraju/Zhang/Möller/Fuhrmann

110

10x10 lattice

Page 110: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machira

Perlin Lattice Gradient Noise

• Random gradients on lattice

– Normalized to unit length

• Scalar product of gradients and distance vectors

• Interpolation of scalar products (higher-order)

• Higher frequencies than lattice value noise

G(x0, y1)

G(x1, y0)

G(x1, y1)

Diff.

G(x0, y0)ju/Zhang/Möller 111

Page 111: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Perlin Lattice Gradient Noisecont.

10x10 lattice noise10x10 lattice gradient noise

© Machiraju/Zhang/Möller/Fuhrmann

112

Page 112: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Perlin Lattice Gradient Noisecont.

20x20 lattice gradient noise10x10 lattice gradient noise

© Machiraju/Zhang/Möller/Fuhrmann

113

Page 113: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Application of Perlin Noise

noise(frequency * x + offset)

noise(2 * x) generates noise

with doubled spatial

frequencies

• Different offset leads to

different noise of same

characteristics

© Machiraju/Zhang/Möller/Fuhrmann

114

Page 114: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Turbulence

• Spectral synthesis– Combine noise of different frequencies:

turbulence(x) = k 1/2k |noise(2kx)|

– Discontinuities in derivatives due to

absolute value

Alternative: k 1/2k noise(2kx)

al– Adding up details proportion

to size (self similarity, fractals)

– Frequency spectrum 1/f

– 1/f fractal noise

© Machiraju/Zhang/Möller/Fuhrmann

115

Page 115: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Turbulence cont.

• Spectral synthesis

– Example for

combination of

different frequencies

© Machiraju/Zhang/Möller/Fuhrmann

116

Page 116: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Turbulence: Examples

© Machiraju/Zhang/Möller/Fuhrmann

117

Page 117: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Noise and Turbulence

Simple noise

© Machiraju/Zhang/Möller/Fuhrmann

118

1/f noise()

Page 118: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Turbulence with Structures

1/f |noise()|

© Machiraju/Zhang/Möller/Fuhrmann

119

sin(x + 1/f |noise()|)

Page 119: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Natural Phenomena

• Example: fireball

• Spatial / color variations

according to turbulence

• Also temporal variations

© Machiraju/Zhang/Möller/Fuhrmann

120

Page 120: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

© Machiraju/Zhang/Möller/Fuhrmann

121

Hypertextures

• Perlin

[K. Perlin , E. M. Hoffert, Hypertexture. Proc. ACM SIGGRAPH 89, 253-262, 1989]

• Idea: mix between geometry and texture

• Extension of solid textures

• Volumetric description of densities

• Types of density functions:

– Object density function (DF)

– Density modulation function (DMF): fuzzy boundaries

• Hypertexture = apply DMFs to a DF repeatedly

• DMF often based on noise or turbulence

• Semi-transparent volume rendering

Page 121: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Hypertextures: Examples

© Machiraju/Zhang/Möller/Fuhrmann

122

Page 122: Texture Mapping - vda.univie.ac.atvda.univie.ac.at/Teaching/Graphics/17s/LectureNotes/12_texture.pdf · Texture Mapping Introduction to Computer Graphics Torsten Möller © Machiraju/Zhang/Möller/Fuhrmann

Hypertextures: Examples cont.

© Machiraju/Zhang/Möller/Fuhrmann

123