Graphics Texture Mapping kucg korea ac kr Graphics

  • Slides: 33
Download presentation
Graphics Texture Mapping 고려대학교 컴퓨터 그래픽스 연구실 kucg. korea. ac. kr Graphics Lab @

Graphics Texture Mapping 고려대학교 컴퓨터 그래픽스 연구실 kucg. korea. ac. kr Graphics Lab @ Korea University

Contents n n n n KUCG Texels and textures Constructing a texture map Texture

Contents n n n n KUCG Texels and textures Constructing a texture map Texture coordinates Texture parameters A rotating cube with texture Texture mapping with images Exercise kucg. korea. ac. kr Graphics Lab @ Korea University

Texels and Textures KUCG Texels – texture elements n Texture coordinates (s, t) n

Texels and Textures KUCG Texels – texture elements n Texture coordinates (s, t) n kucg. korea. ac. kr Graphics Lab @ Korea University

Constructing a Texture Map n KUCG Steps: Read an image for the texture map

Constructing a Texture Map n KUCG Steps: Read an image for the texture map n Define parameters that determine how the texture should be applied n Define texture coordinates for the vertices n n Ex: making the image into a 2 D texture map GLubyte myimage[64][3]; gl. Enable(GL_TEXTURE_2 D); gl. Tex. Image 2 D(GL_TEXTURE_2 D, 0, 3, 64, 0, GL_RGB, GL_UNSIGNED_BYTE, myimage); kucg. korea. ac. kr Graphics Lab @ Korea University

1 D, 2 D, & 3 D Texture Maps KUCG void gl. Tex. Image

1 D, 2 D, & 3 D Texture Maps KUCG void gl. Tex. Image 1 D(GLenum target, GLint level, GLint iformat, GLsizei width, GLint border, GLenum format, GLenum type, Glvoid *texels); void gl. Tex. Image 2 D(GLenum target, GLint level, GLint iformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, Glvoid *texels); void gl. Tex. Image 3 D(GLenum target, GLint level, GLint iformat, GLsizei width, GLsizei height, Glsizei depth, GLint border, GLenum format, GLenum type, Glvoid *texels); kucg. korea. ac. kr Graphics Lab @ Korea University

2 D Texture Map n KUCG Texture map as a continuous image in (s,

2 D Texture Map n KUCG Texture map as a continuous image in (s, t) space and as a discrete image Texture Map kucg. korea. ac. kr Texture Image Graphics Lab @ Korea University

Texture Coordinates (1/2) n KUCG Mapping between points on geometric objects and texels void

Texture Coordinates (1/2) n KUCG Mapping between points on geometric objects and texels void gl. Tex. Coord{1234}{sifd}(TYPE scoord, . . . ); void gl. Tex. Coord{1234}{sifd}v(TYPE *coord); n Ex: mapping the texture to a quadrilateral gl. Begin(GL_QUADS); gl. Tex. Coord 2 f(0. 0, gl. Tex. Coord 2 f(1. 0, gl. End(); kucg. korea. ac. kr 0. 0); 1. 0); 0. 0); gl. Vertex 3 fv(vertex[0]); gl. Vertex 3 fv(vertex[1]); gl. Vertex 3 fv(vertex[2]); gl. Vertex 3 fv(vertex[3]); Graphics Lab @ Korea University

Texture Coordinates (2/2) n KUCG Applying a checkerboard texture to a quadrilateral Texture Map

Texture Coordinates (2/2) n KUCG Applying a checkerboard texture to a quadrilateral Texture Map kucg. korea. ac. kr Quadrilateral Graphics Lab @ Korea University

Texture Parameters (1/3) n KUCG Control over how the texture is applied to the

Texture Parameters (1/3) n KUCG Control over how the texture is applied to the surface void gl. Tex. Parameter{if}(GLenum target, GLenum name, TYPE value); void gl. Tex. Parameter{if}v(GLenum target, GLenum name, TYPE *value); n Ex: deciding what to do if values are out of (0, 1) gl. Tex. Parameter(GL_TEXTURE_2 D, GL_TEXTURE_WRAP_S, GL_REPEAT); gl. Tex. Parameter(GL_TEXTURE_2 D, GL_TEXTURE_WRAP_T, GL_REPEAT); n GL_CLAMP kucg. korea. ac. kr Graphics Lab @ Korea University

Texture Parameters (2/3) n KUCG Preimage of the pixel n Texture mapping is not

Texture Parameters (2/3) n KUCG Preimage of the pixel n Texture mapping is not really applied to the surface but rather a pixel in screen coordinates Magnification – each texel covers multiple pixels n Minification – each pixel covers multiple texels n Magnification kucg. korea. ac. kr Minification Graphics Lab @ Korea University

Texture Parameters (3/3) n KUCG Point sampling n Open. GL uses to average a

Texture Parameters (3/3) n KUCG Point sampling n Open. GL uses to average a 2 X 2 array of neighboring texels gl. Tex. Parameter(GL_TEXTURE_2 D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); gl. Tex. Parameter(GL_TEXTURE_2 D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); n GL_LINEAR kucg. korea. ac. kr Graphics Lab @ Korea University

A Rotating Cube with Texture kucg. korea. ac. kr KUCG Graphics Lab @ Korea

A Rotating Cube with Texture kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Constructor kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Constructor kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Draw. Quad( ) kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Draw. Quad( ) kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Draw. Scene( ) kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Draw. Scene( ) kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

A Color Cube kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

A Color Cube kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Texture Image kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Texture Image kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Load. Texture( ) kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Load. Texture( ) kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Draw. Quad( ) kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Draw. Quad( ) kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Draw. Scene( ) kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Draw. Scene( ) kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

A Color Cube with Texture kucg. korea. ac. kr KUCG Graphics Lab @ Korea

A Color Cube with Texture kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Exercise (1) n KUCG Change the texture coordinates, parameters for texture mapping kucg. korea.

Exercise (1) n KUCG Change the texture coordinates, parameters for texture mapping kucg. korea. ac. kr Graphics Lab @ Korea University

Texture Images n KUCG Load a BMP file for a texture image kucg. korea.

Texture Images n KUCG Load a BMP file for a texture image kucg. korea. ac. kr Graphics Lab @ Korea University

Open. GL Auxiliary Library kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Open. GL Auxiliary Library kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Project Settings kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Project Settings kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

New Definition kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

New Definition kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Load. Texture( ) kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Load. Texture( ) kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Result – Texture Mapping (1) kucg. korea. ac. kr KUCG Graphics Lab @ Korea

Result – Texture Mapping (1) kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Multiple Texture Images kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Multiple Texture Images kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Load. Texture( ) kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Load. Texture( ) kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Draw. Scene( ) kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Draw. Scene( ) kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Result – Texture Mapping (2) kucg. korea. ac. kr KUCG Graphics Lab @ Korea

Result – Texture Mapping (2) kucg. korea. ac. kr KUCG Graphics Lab @ Korea University

Exercise (2) n KUCG Set the background by texture mapping kucg. korea. ac. kr

Exercise (2) n KUCG Set the background by texture mapping kucg. korea. ac. kr Graphics Lab @ Korea University