Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Texture Mapping 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr."— Presentation transcript:

1 Texture Mapping 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr

2 Contents 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

3 Texels and Textures Texels – texture elements
Texture coordinates (s, t) kucg.korea.ac.kr

4 Constructing a Texture Map
Steps: Read an image for the texture map Define parameters that determine how the texture should be applied Define texture coordinates for the vertices Ex: making the image into a 2D texture map GLubyte myimage[64][64][3]; glEnable(GL_TEXTURE_2D); glTexImage2D(GL_TEXTURE_2D, 0, 3, 64, 64, 0, GL_RGB, GL_UNSIGNED_BYTE, myimage); kucg.korea.ac.kr

5 1D, 2D, & 3D Texture Maps void glTexImage1D(GLenum target, GLint level, GLint iformat, GLsizei width, GLint border, GLenum format, GLenum type, Glvoid *texels); void glTexImage2D(GLenum target, GLint level, GLint iformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, Glvoid *texels); void glTexImage3D(GLenum target, GLint level, GLint iformat, GLsizei width, GLsizei height, Glsizei depth, GLint border, GLenum format, GLenum type, Glvoid *texels); kucg.korea.ac.kr

6 2D Texture Map Texture map as a continuous image in (s, t) space and as a discrete image Texture Map Texture Image kucg.korea.ac.kr

7 Texture Coordinates (1/2)
Mapping between points on geometric objects and texels Ex: mapping the texture to a quadrilateral void glTexCoord{1234}{sifd}(TYPE scoord, ...); void glTexCoord{1234}{sifd}v(TYPE *coord); glBegin(GL_QUADS); glTexCoord2f(0.0, 0.0); glVertex3fv(vertex[0]); glTexCoord2f(0.0, 1.0); glVertex3fv(vertex[1]); glTexCoord2f(1.0, 1.0); glVertex3fv(vertex[2]); glTexCoord2f(1.0, 0.0); glVertex3fv(vertex[3]); glEnd(); kucg.korea.ac.kr

8 Texture Coordinates (2/2)
Applying a checkerboard texture to a quadrilateral Texture Map Quadrilateral kucg.korea.ac.kr

9 Texture Parameters (1/3)
Control over how the texture is applied to the surface Ex: deciding what to do if values are out of (0, 1) GL_CLAMP void glTexParameter{if}(GLenum target, GLenum name, TYPE value); void glTexParameter{if}v(GLenum target, GLenum name, TYPE *value); glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, kucg.korea.ac.kr

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

11 Texture Parameters (3/3)
Point sampling OpenGL uses to average a 2X2 array of neighboring texels GL_LINEAR glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, kucg.korea.ac.kr

12 A Rotating Cube with Texture
kucg.korea.ac.kr

13 Constructor kucg.korea.ac.kr

14 DrawQuad( ) kucg.korea.ac.kr

15 DrawScene( ) kucg.korea.ac.kr

16 A Color Cube kucg.korea.ac.kr

17 Texture Image kucg.korea.ac.kr

18 LoadTexture( ) kucg.korea.ac.kr

19 DrawQuad( ) kucg.korea.ac.kr

20 DrawScene( ) kucg.korea.ac.kr

21 A Color Cube with Texture
kucg.korea.ac.kr

22 Exercise (1) Change the texture coordinates, parameters for texture mapping kucg.korea.ac.kr

23 Texture Images Load a BMP file for a texture image kucg.korea.ac.kr

24 OpenGL Auxiliary Library
kucg.korea.ac.kr

25 Project Settings kucg.korea.ac.kr

26 New Definition kucg.korea.ac.kr

27 LoadTexture( ) kucg.korea.ac.kr

28 Result – Texture Mapping (1)
kucg.korea.ac.kr

29 Multiple Texture Images
kucg.korea.ac.kr

30 LoadTexture( ) kucg.korea.ac.kr

31 DrawScene( ) kucg.korea.ac.kr

32 Result – Texture Mapping (2)
kucg.korea.ac.kr

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


Download ppt "Texture Mapping 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr."

Similar presentations


Ads by Google