1. Trang chủ
  2. » Giáo Dục - Đào Tạo

Texture mapping (đồ họa máy TÍNH SLIDE)

51 9 2

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 51
Dung lượng 9,56 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

OpenGL Texture Mapping• Apply a 1D, 2D, or 3D image to geometric... Idea: Use Map Shape• Map shapes correspond to various projections – Planar, Cylindrical, Spherical • First, map square

Trang 1

Texture Mapping

Trang 2

Texture Mapping

• Important topic: nearly all objects textured

– Wood grain, faces, bricks and so on

– Adds visual detail to scenes

• Meant as a fun and practically useful lecture

Polygonal model With surface texture

Trang 3

Adding Visual Detail

• Basic idea: use images instead of more

polygons to represent fine scale color variation

3

Trang 5

Option: Varieties of projections

[Paul Bourke] 5

Trang 6

Option: unfold the surface

[Piponi2000]

Trang 7

Option: make an atlas

[Sander2001]

7

Trang 8

Option: it’s the artist’s problem

Trang 9

OPENGL TEXTURE MAPPING

9

Trang 10

OpenGL Texture Mapping

• Apply a 1D, 2D, or 3D image to geometric

Trang 11

How to map object to texture?

To each vertex (x, y, z in object coordinates),

must associate 2D texture coordinates (s, t)

So texture fits “nicely” over object

s t

Trang 12

Idea: Use Map Shape

• Map shapes correspond to various projections

– Planar, Cylindrical, Spherical

• First, map (square) texture to basic map shape

• Then, map basic map shape to object

– Or vice versa: Object to map shape, map shape to

square

• Usually, this is straightforward

– Maps from square to cylinder, plane, sphere well

defined

– Maps from object to these are simply spherical,

cylindrical, cartesian coordinate systems

Trang 13

Planar mapping

• Like projections, drop z coord (s, t) = (x, y)

• Problems: what happens near z = 0?

13

Trang 14

Cylindrical Mapping

• Cylinder: r, θ, z with (s, t) = (θ/(2π), z)

– Note seams when wrapping around (θ = 0 or 2π)

Trang 15

Spherical Mapping

• Convert to spherical coordinates: use latitude/long

– Singularities at north and south poles

15

Trang 16

Cube Mapping

Trang 17

Cube Mapping

17

Trang 18

Texture Mapping and the OpenGL Pipeline

• Images and geometry flow through separate

pipelines that join at the rasterizer

– "complex" textures do not affect geometric complexity

geometry pipeline vertices

pixel pipeline image

rasterizer

Trang 20

• Assign texture coordinates to vertices

• Specify texture parameters

– Wrapping, filtering

Trang 21

Applying Textures II

• Specify textures in texture objects

• Set texture filter

• Set texture function

• Set texture wrap mode

• Set optional perspective correction hint

• Bind texture object

• Enable texturing

• Supply texture coordinates for vertex

– Coordinates can also be generated

21

Trang 22

Texture Objects

• Like display lists for texture images

– One image per texture object

– May be shared by several graphics contexts

• Generate texture names

glGenTextures(n, texIds[]);

– Returns n currently unused names for texture objects

in the array texIds

• Delete texture objects

glDeleteTextures(n, texIds[])

Trang 23

Texture Objects (cont.)

• Create texture objects with texture data and state

– When binding to a texId value of zero, OpenGL stops

using texture objects and returns to the default texture.

• Bind textures before using

glBindTexture(target, id);

23

Trang 24

Specify Texture Image

• Define a texture image from an array of texels in CPU memory

glTexImage2D( target, level, components,

w, h, border, format, type,

texels[] );

– dimensions of image must be powers of 2

• Texel colors are processed by pixel pipeline

– pixel scales, biases and lookups can be done

Trang 25

Converting A Texture Image

• If dimensions of image are not power of 2

gluScaleImage(format, w_in, h_in,

type_in, data_in[], w_out, h_out,

type_out, data_out[]);

– *_in is for source image

– *_out is for destination image

• Image interpolated and filtered during scaling

25

Trang 26

Specifying a Texture: Other Methods

• Use frame buffer as source of texture image

– uses current buffer as source image

Trang 27

Mapping a Texture

• Based on parametric texture coordinates

• glTexCoord*() specified at each vertex

Trang 28

Generating Texture Coordinates

• Automatically generate texture coords

Trang 29

Tutorial: Texture

29

Trang 30

Texture Application Methods

– How to mix primitive’s color with texture’s color

• blend, modulate or replace texels

Trang 35

Perspective Correction Hint

• Texture coordinate and color interpolation

– either linearly in screen space

– or using depth/perspective values (slower)

• Noticeable for polygons “on edge”

Trang 36

Is There Room for a Texture?

• Query largest dimension of texture image

– typically largest square texture

– doesn’t consider internal format size

• glGetIntegerv(GL_MAX_TEXTURE_SIZE,

&size)

• Texture proxy

– will memory accommodate requested texture size?

– no image specified; placeholder

– if texture won’t fit, texture state variables set to 0

• doesn’t know about other textures

• only considers whether this one texture will fit all of memory

Trang 37

Texture Residency

• Working set of textures

– high-performance, usually hardware accelerated

– textures must be in texture objects

– a texture in the working set is resident

– for residency of current texture, check

GL_TEXTURE_RESIDENT state

• If too many textures, not all are resident

– can set priority to have some kicked out first

– establish 0.0 to 1.0 priorities for texture objects

37

Trang 38

TEXTURE MAPPING APPLICATIONS

Trang 39

Texture Mapping Applications

• Modulation, light maps

Trang 40

) (

) (

( (

,

(s t I K I K N L K V R n S I K I K I T

Trang 41

Bump Mapping

• Texture = change in surface normal!

41

Trang 42

Displacement Mapping

Trang 43

Illumination Maps

• Quake introduced illumination maps or light maps to

capture lighting effects in video games

Trang 44

Environment Maps

Images from Illumination and Reflection Maps:

Simulated Objects in Simulated and Real Environments

Gene Miller and C Robert Hoffman

Trang 45

• Compute on the fly,

e.g Perlin noise 

45

Trang 46

Procedural Texture Gallery

Ngày đăng: 29/03/2021, 08:19

TỪ KHÓA LIÊN QUAN

w