texture mapping - cs.purdue.edu · • generic image to represent material – tile pattern to...

23
1 1 Texture Mapping 2 Overview Modeling with textures – motivation – texture coordinates Texture mapping implementation Anti-aliasing and level of detail

Upload: others

Post on 10-Oct-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Texture Mapping - cs.purdue.edu · • Generic image to represent material – tile pattern to cover big surface bark veneer bricks 12 Tiling • Repeat pattern. 7 13 Tiling • Repeat

1

1

Texture Mapping

2

Overview

• Modeling with textures– motivation– texture coordinates

• Texture mapping implementation• Anti-aliasing and level of detail

Page 2: Texture Mapping - cs.purdue.edu · • Generic image to represent material – tile pattern to cover big surface bark veneer bricks 12 Tiling • Repeat pattern. 7 13 Tiling • Repeat

2

3

Texture mapping

• Model surface-detail with images– wrap objects with photographs– model and render color or “flat” detail– does not capture 3D detail

4

Texture mapping example

• Model t-shirt with logo– no need to model the letters

and engine with triangles– use large base polygon– color it with the photograph

Page 3: Texture Mapping - cs.purdue.edu · • Generic image to represent material – tile pattern to cover big surface bark veneer bricks 12 Tiling • Repeat pattern. 7 13 Tiling • Repeat

3

5

Texture mapping example

• Subtle wall lighting– no need to compute it at

every frame– no need to model it with

a lot of constant color triangles

6

Texture mapping example

• Subtle wall lighting– paste photograph on

large polygon

Page 4: Texture Mapping - cs.purdue.edu · • Generic image to represent material – tile pattern to cover big surface bark veneer bricks 12 Tiling • Repeat pattern. 7 13 Tiling • Repeat

4

7

Texture mapping example

• Non-planar surfaces work also

8

Texture mapping example

• Non-planar surfaces work also– subdivide surface into planar

patches– assign photograph subregions

to each individual patch

Page 5: Texture Mapping - cs.purdue.edu · • Generic image to represent material – tile pattern to cover big surface bark veneer bricks 12 Tiling • Repeat pattern. 7 13 Tiling • Repeat

5

9

Texture mapping example

• Non-planar surfaces work also– subdivide surface into planar

patches– assign photograph subregions

to each individual patch

10

Texture mapping example

• Non-planar surfaces work also– subdivide surface into planar

patches– assign photograph subregions

to each individual patch

Page 6: Texture Mapping - cs.purdue.edu · • Generic image to represent material – tile pattern to cover big surface bark veneer bricks 12 Tiling • Repeat pattern. 7 13 Tiling • Repeat

6

11

Texture mapping example

• Generic image to represent material– tile pattern to cover big

surface

bark

veneer

bricks

12

Tiling

• Repeat pattern

Page 7: Texture Mapping - cs.purdue.edu · • Generic image to represent material – tile pattern to cover big surface bark veneer bricks 12 Tiling • Repeat pattern. 7 13 Tiling • Repeat

7

13

Tiling

• Repeat pattern

14

Tiling

• Repeat pattern

Page 8: Texture Mapping - cs.purdue.edu · • Generic image to represent material – tile pattern to cover big surface bark veneer bricks 12 Tiling • Repeat pattern. 7 13 Tiling • Repeat

8

15

Tiling

• Repeat pattern– reduce seems by

mirroring

16

Tiling

• Repeat pattern– reduce seems by

mirroring

Page 9: Texture Mapping - cs.purdue.edu · • Generic image to represent material – tile pattern to cover big surface bark veneer bricks 12 Tiling • Repeat pattern. 7 13 Tiling • Repeat

9

17

Tiling

• Repeat pattern– reduce seems by

mirroring

18

Tiling

• Repeat pattern– reduce seems by

mirroring

Page 10: Texture Mapping - cs.purdue.edu · • Generic image to represent material – tile pattern to cover big surface bark veneer bricks 12 Tiling • Repeat pattern. 7 13 Tiling • Repeat

10

19

Tiling

• Repeat pattern– reduce seems by

mirroring– reduce seems by

choosing tile that covers one period of repeated texture

20

Tiling

Page 11: Texture Mapping - cs.purdue.edu · • Generic image to represent material – tile pattern to cover big surface bark veneer bricks 12 Tiling • Repeat pattern. 7 13 Tiling • Repeat

11

21

Texture mapping limitations

22

Bricks are similar not identical

Page 12: Texture Mapping - cs.purdue.edu · • Generic image to represent material – tile pattern to cover big surface bark veneer bricks 12 Tiling • Repeat pattern. 7 13 Tiling • Repeat

12

23

Texture mapping limitations

• Shiny floor– reflection is

view dependent

24

Texture coordinates

• Mechanism for attaching the texture map to the surface modeled– a pair of floats (s, t) for each triangle vertex– corners of the image are (0, 0), (0, 1), (1, 1),

and (1, 0)– tiling indicated with tex. coords. > 1– texels – color samples in texture maps

Page 13: Texture Mapping - cs.purdue.edu · • Generic image to represent material – tile pattern to cover big surface bark veneer bricks 12 Tiling • Repeat pattern. 7 13 Tiling • Repeat

13

25

Texture coordinates

x

y

z

O

P2(0, 0)P1(1, 0)

P4(1, 1)

P3(0, 1)

26

Overview

• Modeling with textures– motivation– texture coordinates

• Texture mapping implementation• Anti-aliasing and level of detail

Page 14: Texture Mapping - cs.purdue.edu · • Generic image to represent material – tile pattern to cover big surface bark veneer bricks 12 Tiling • Repeat pattern. 7 13 Tiling • Repeat

14

27

Overview

• Modeling with textures– motivation– texture coordinates

• Texture mapping implementation• Anti-aliasing and level of detail

28

Texture mapping

x

y

z

OC

c

a

b

P1’

P2(0, 0)

P2’

P3’

P1(1, 0)

P4(1, 1)

P3(0, 1)

Page 15: Texture Mapping - cs.purdue.edu · • Generic image to represent material – tile pattern to cover big surface bark veneer bricks 12 Tiling • Repeat pattern. 7 13 Tiling • Repeat

15

29

Find texel for current pixel

P1’(u1, v1, s1, t1)

P2’(u2, v2, s2, t2)P3’(u3, v3, s3, t3)

P’(u, v, s, t)

30

Texture mapping

x

y

z

OC

c

a

b

P1’

P2(s2, t2)

P2’

P3’

P1(s1, t1)

P3(s3, t3)

P (s, t)

P’

Page 16: Texture Mapping - cs.purdue.edu · • Generic image to represent material – tile pattern to cover big surface bark veneer bricks 12 Tiling • Repeat pattern. 7 13 Tiling • Repeat

16

31

Texture mapping

x

y

z

OC

c

a

b

P1’

P2(s2, t2)

P2’

P3’

P1(s1, t1)

P3(s3, t3)

P (s, t)

P’

problem: compute the texture coordinates for

an interior pixel

32

Texture mapping

x

y

z

OC

c

a

b

P1’

P2(s2, t2)

P2’

P3’

P1(s1, t1)

P3(s3, t3)

P (s, t)

P’

solution: interpolate vertex texture coordinates

Page 17: Texture Mapping - cs.purdue.edu · • Generic image to represent material – tile pattern to cover big surface bark veneer bricks 12 Tiling • Repeat pattern. 7 13 Tiling • Repeat

17

33

Overview

• Modeling with textures– motivation– texture coordinates

• Texture mapping implementation• Anti-aliasing and level of detail

34

Overview

• Modeling with textures– motivation– texture coordinates

• Texture mapping implementation• Anti-aliasing and level of detail

Page 18: Texture Mapping - cs.purdue.edu · • Generic image to represent material – tile pattern to cover big surface bark veneer bricks 12 Tiling • Repeat pattern. 7 13 Tiling • Repeat

18

35

Aliasingsampling locations (desired image pixel centers)

texture map

36

Aliasingsampling locations (desired image pixel centers)

texture map

Page 19: Texture Mapping - cs.purdue.edu · • Generic image to represent material – tile pattern to cover big surface bark veneer bricks 12 Tiling • Repeat pattern. 7 13 Tiling • Repeat

19

37

Aliasing

• High frequencies pose as lower frequencies– display resolution gives maximum displayable

frequency– if not sufficient high frequencies are called

(aliased as) low frequencies• Nyquist law

– max frequency displayable is half the sampling frequency

38

Nyquist lawfor given texture map, one should sample at least this frequently to avoid aliasing

Page 20: Texture Mapping - cs.purdue.edu · • Generic image to represent material – tile pattern to cover big surface bark veneer bricks 12 Tiling • Repeat pattern. 7 13 Tiling • Repeat

20

39

Nyquist lawfor given texture map resolution, one should sample at least this frequently to avoid aliasing

40

Possible Antialiasing

Solution

convolution with 2 output-pixel-wide kernel EXPENSIVE

Page 21: Texture Mapping - cs.purdue.edu · • Generic image to represent material – tile pattern to cover big surface bark veneer bricks 12 Tiling • Repeat pattern. 7 13 Tiling • Repeat

21

41

Level of detail

• Adapt texture resolution to desired image resolution

• Mip-mapping– texture is filtered as preprocess to several

resolutions– at runtime

• find out required resolution• use corresponding version of texture map

42

Mip-mapping: example

256x256 128x128 64x64 …

Page 22: Texture Mapping - cs.purdue.edu · • Generic image to represent material – tile pattern to cover big surface bark veneer bricks 12 Tiling • Repeat pattern. 7 13 Tiling • Repeat

22

43

Trilinear filtering

• Use two most appropriate resolutions of texture map– lookup color values with bilinear interpolation

in each texture version– linearly interpolate in between the two color

values

44

Trilinear filtering: example

linear

bilinear bilinear

Page 23: Texture Mapping - cs.purdue.edu · • Generic image to represent material – tile pattern to cover big surface bark veneer bricks 12 Tiling • Repeat pattern. 7 13 Tiling • Repeat

23

45

Anisotropic filtering

• Different levels of detail are needed along the two directions in the texture map– filter differently along s and t

312

63

desired image view of polygon • trilinear interpolation between levels 32 and 64 blurs too much along the s direction

• use levels 256 – 512 for s and 32 – 64 for t