1 / 49

Textures

Textures. Lecture 9 SE309-Computer graphics. Outline. Textures Creating Textures Applying Textures Magnification Minification Other Problems Assignment. Outline. Textures Creating Textures Applying Textures Magnification Minification Other Problems Assignment. Textures.

alesia
Download Presentation

Textures

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. Textures Lecture 9 SE309-Computer graphics

  2. Outline • Textures • Creating Textures • Applying Textures • Magnification • Minification • Other Problems • Assignment

  3. Outline • Textures • Creating Textures • Applying Textures • Magnification • Minification • Other Problems • Assignment

  4. Textures Definition (Texture) • A texture is an image that can be “pasted” onto a surface. • The image may be a simple one that was generated internally, such as a checkerboard pattern, or it may be a photograph (e.g., .bmp file or .jpg file) that was read from a file.

  5. Texture Format • There are many internal formats for textures. • Among there are the following. • GL_RGB - Each texel (texture element) stored in 3 bytes (red, green, blue) • GL_RGBA - Each texel stored in 4 bytes (red, green, blue, alpha) • GL_R3_G3_B2 - Each texel stored in 1 byte (3 red bits, 3 green bits, 2 blue bits), etc. • We will use the GL_RGB format.

  6. Outline • Textures • Creating Textures • Applying Textures • Magnification • Minification • Other Problems • Assignment

  7. Creating Textures • The GL_RGB texture image is created as a 3-dimensional array. GLubyte image[rows][cols][3]; • Think of it as a 2-dimensional array of color vectors. • Each vector contains the red, green, and blue values as unsigned integers from 0 to 255.

  8. Creating Textures • There are also 1-dimensional textures, which are pasted onto lines and 3-dimensional textures, which are pasted into solids. • We will do only 2-dimensionsal textures.

  9. Creating Textures • The dimensions of a texture image must be powers of 2, but they need not be the same power of 2. • Typical dimensions • 256x256 • 256x512 • 32x32

  10. Example • A brick wall texture may be designed as an 8x8 texture.

  11. Tiling Textures • Often textures are “tiled” across a surface. • When they are tiled, it is desirable that the images match left-to-right and top-to-bottom. • The brick wall texture:

  12. Tiling Textures • Tiling textures works well if the texture is supposed to have a regular pattern, such as in the case of the brick wall. • Other textures look better if there is no discernable pattern, such as leaves..

  13. Tiling Textures

  14. Window Texture • Other textures are not meant to be tiled.

  15. Outline • Textures • Creating Textures • Applying Textures • Magnification • Minification • Other Problems • Assignment

  16. Applying Textures • When a texture is applied to a polygon, the texels are mapped to the pixels of the rasterized polygon. • This usually leads to one of two situations. • One texel maps to several pixels. • Several texels map to one pixel.

  17. Applying Textures Definition (Magnification) • Magnification is mapping one texel to several pixels (because the texel is magnified). Definition (Minification) • Minification is mapping several texels to one pixel.

  18. Applying Textures • When mapping texels to pixels, we may choose between • Applying the nearest texel. • Interpolating among texels. • Interpolation uses a weighted average of the 4 nearest texels, weighted by distance. • This is called bilinear interpolation.

  19. Outline • Textures • Creating Textures • Applying Textures • Magnification • Minification • Other Problems • Assignment

  20. Magnification of Texels (Nearest)

  21. Magnification of Texels (Nearest)

  22. Magnification of Texels (Nearest) Image copied and pasted from demo program

  23. Magnification of Texels (Interpolated)

  24. Magnification of Texels (Interpolated)

  25. Magnification of Texels (Interpolated) Image copied and pasted from demo program

  26. Close-up of Texture 1:1 (Nearest) Close-up of 1:1 texture (nearest) copied from demo program

  27. Close-up of Texture 1:1 (Interpolated) Close-up of 1:1 texture (interpolated) copied from demo program

  28. Close-up of Texture 2:3 (Nearest) Close-up of 2:3 nearest texture Copied from demo program

  29. Close-up of Texture 1:1 (Interpolated) Close-up of 2:3 interpolated texture Copied from demo program

  30. Outline • Textures • Creating Textures • Applying Textures • Magnification • Minification • Other Problems • Assignment

  31. Minification of Texels (Nearest)

  32. Minification of Texels (Nearest)

  33. Minification of Texels (Nearest)

  34. Minification of Texels (Interpolated)

  35. Minification of Texels (Interpolated)

  36. Minification of Texels (Interpolated)

  37. The Mapping is not Exact

  38. The Mapping is not Exact

  39. Applying Textures Often the situation is even more complicated.

  40. Applying Textures Often the situation is even more complicated.

  41. Outline • Textures • Creating Textures • Applying Textures • Magnification • Minification • Other Problems • Assignment

  42. Other Problems There can be undesirable effects

  43. Other Problems There can be undesirable effects

  44. Other Problems There can be undesirable effects (nearest)

  45. Other Problems There can be undesirable effects (interpolated)

  46. Other Problems There can be undesirable effects (nearest)

  47. Other Problems There can be undesirable effects (nearest)

  48. Outline • Textures • Creating Textures • Applying Textures • Magnification • Minification • Other Problems • Assignment

  49. Homework • Read Chapter8 – Texture mapping.

More Related