1 / 36

OpenGL Programming Guide : Texture Mapping

OpenGL Programming Guide : Texture Mapping. 2004. 02. 10. Yoo jin wook Korea Univ. Computer Graphics Lab. Texture Mapping ( 1/3 ). Texture Simply rectangular arrays of data ex) Color data, luminance data, color & alpha data Texel Individual values in a texture array

marc
Download Presentation

OpenGL Programming Guide : Texture Mapping

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. OpenGL Programming Guide : Texture Mapping 2004. 02. 10. Yoo jin wook Korea Univ. Computer Graphics Lab

  2. Texture Mapping ( 1/3 ) • Texture Simply rectangular arrays of data ex) Color data, luminance data, color & alpha data • Texel Individual values in a texture array cf) texel ≠Pixel  requires filtering

  3. Texture Mapping ( 2/3 )

  4. Texture Mapping ( 3/3 ) • An Overview & an Example • Specifying the Texture • Filtering • Texture Objects • Texture Functions • Assigning Texture Coordinates • Automatic Texture-Coordinate Generation • Advanced Feature (Multitexturing)

  5. An Overview & an Example ( 1/2 ) • Steps in Texture Mapping 1. Create object & Specify a texture 2. Indicate how the texture is to be applied to each pixel 3. Enable Texture mapping 4. Draw the scene

  6. Example 9-1 An Overview & an Example ( 2/2 )

  7. Specifying the Texture ( 1/3 ) target : GL_TEXTURE_2D, GL_PROXY_TEXTURE_2D internalFormat : 1~4 (R,G,B,A) Format : GL_RGB, GL_RGBA, GL_RED ….

  8. Specifying the Texture ( 2/3 )

  9. Specifying the Texture ( 3/3 ) : Create a two-dimensional texture using framebuffer

  10. Texture Proxy ( 1/3 ) • Texture Proxy : answers the question of whether a texture is capable of being loaded into texture memory • Steps in Texture Proxy 1. Create texture proxy with glTexImage2D( ) 2. Query the texture state variables withglGetTexLevelParameter*( )

  11. Texture Proxy ( 2/3 ) pname : GL_TEXTURE_WIDTH, GL_TEXTURE_DEPTH GL_TEXTURE_HEIGHT…..

  12. Texture Proxy ( 3/3 ) Ex) Glint width; glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGBA8, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);

  13. Replacing a Texture Image ( 1/2 ) xoffset, yoffset : texel offset in the x-,y- direction with (0,0) at the lower left corner of the texture

  14. Example 9-3 Replacing a Texture Image ( 2/2 )

  15. Multiple Levels of Detail ( 1/4 ) • Mipmap : series of prefiltered texture maps of decreasing resolutions ->openGL automatically determines which texture map to use based on the size(in pixels) ->must provide all sizes of your texture in powers of 2 between the largest size and 1×1 map ex) 64×32 : 32×8, 16×4, 8×2, 4×1, 2×1, 1×1

  16. Example 9-5 Multiple Levels of Detail ( 2/4 )

  17. Multiple Levels of Detail ( 3/4 ) • Automated Mipmap Generation : define the pyramid of mipmaps down to a resolution 1×1

  18. Multiple Levels of Detail ( 4/4 ) • Advanced Mipmap Details glTexParameter*( ) ** : openGL 1.2

  19. Filtering ( 1/2 )

  20. Filtering ( 2/2 ) glTexParameter*( )

  21. Texture Objects ( 1/4 ) • Steps 1. Generate texture names 2. Initially bind texture objects to texture data 3. See if you have enough space for all your texture object 4. Bind and rebind texture objects

  22. Texture Objects ( 2/4 ) • Naming A texture Object

  23. Texture Objects ( 3/4 ) • Creating and Using Texture Objects

  24. Texture Objects ( 4/4 ) • A Working Set of Resident Textures : queries the texture residence status of the n texture object

  25. Texture Functions ( 1/3 ) target : GL_TEXTURE_ENV_MODE, GL_TEXTURE_ENV_COLOR

  26. Texture Functions ( 2/3 ) ** : used only if the GL_BLEND texture function has been specified

  27. Texture Functions ( 3/3 ) < GL_DECAL ≈ GL_REPLACE> < GL_MODULATE >

  28. Assigning Texture Coordinates ( 1/3 )

  29. Assigning Texture Coordinates ( 2/3 )

  30. Assigning Texture Coordinates ( 3/3 ) • Repeat & Clamp glTexImage2D(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT/GL_CLAMP); glTexImage2D(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT/GL_CLAMP);

  31. Automatic Texture-CoordinateGeneration ( 1/2 ) coord : GL_S, GL_T, GL_R, GL_Q pname : GL_TEXTURE_GEN_MODE, GL_OBJECT_PLANE, GL_EYE_PLANE param : GL_OBJECT_LINEAR, GL_EYE_LINEAR, GL_SHPERE_MAP or an array of texture generation parameters

  32. <eye coordinate> <object coordinate> <slanted coordinate> Automatic Texture-CoordinateGeneration ( 2/2 )

  33. Multitexturing ( 1/4 )

  34. Multitexturing ( 2/4 ) • Steps 1. Check to see if multitexturing is supported - glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, ….) 2. For each texturing unit, establish the texture state - glActiveTextureARB() 3. During vertex specification, use glMultiTexCoord*ARB()

  35. Multitexturing ( 3/4 ) • Establishing Texture Unit GLuint texNames[2]; ……………………………. glActiveTextureARB(GL_TEXTURE0_ARB); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texNames[0]); …………………………….. glActiveTextureARB(GL_TEXTURE1_ARB); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texNames[1]); ……………………………..

  36. Multitexturing ( 4/4 ) • Specifying glBegin(GL_TRIANGLES); glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 0.0); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, 0.0); glVertex2f(0.0, 0.0); glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.5, 1.0); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.5, 0.0); glVertex2f(50.0, 100.0); glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0, 0.0); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0, 1.0); glVertex2f(100.0, 0.0) glEnd();

More Related