COMP471 Computer Graphics - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

COMP471 Computer Graphics

Description:

Create complex appearance w/o much computational effort ... A detailed pattern repeated many times to tile a ... like a reflection from a chrome hemisphere ... – PowerPoint PPT presentation

Number of Views:60
Avg rating:3.0/5.0
Slides: 15
Provided by: alcorCo
Category:

less

Transcript and Presenter's Notes

Title: COMP471 Computer Graphics


1
COMP471 Computer Graphics
  • OpenGL Texture Mapping

2
The Need
  • Create complex appearance w/o much computational
    effort

3
Texture Def
  • A detailed pattern repeated many times to tile a
    given plane
  • A multidimensional image mapped to a multidim.
    space.

4
Texture Mapping
  • A technique to improve the appearance of the
    objects shaded with a light model
  • Function of mapping an image onto a 3D surface
  • Provide color details for complex surfaces

5
Viewing
  • 2D Texture Space
  • 3D Model Space
  • 2D Screen Space

parameterization
compound mapping
projection
6
Texture in OpenGL
  • Identified by an integer name
  • The procedure
  • Need to generate names first (glGenTextures())
  • Load images (see texture.h for BMPLoader for
    example)
  • Bind loaded binary image data to the integer name
    (glBindTexture)
  • Set parameters (glTexParameter())
  • Build mipmaps (e.g. gluBuild2DMipmaps())
  • When drawing an object
  • Enable texturing
  • Specify a texture by its name
  • Disable texture mode

7
Reading Textures
  • readAllTextures()

8
Mapping Texture on Flat Surfaces and Quadric
Objects
  • Cube
  • Sphere
  • Spheremap

9
Cube
glEnable(GL_TEXTURE_2D) glBindTexture(GL_TEXTURE_
2D, m_aiTexNamesp_iFaceColor) draw cubes
face glDisable(GL_TEXTURE_2D)
10
Sphere
glEnable(GL_TEXTURE_2D) glBindTexture(GL_TEXTURE_
2D, m_iTexName) GLUquadricObj l_poQuadric
gluNewQuadric() gluQuadricDrawStyle(l_poQuadric,
GLU_FILL) gluQuadricNormals(l_poQuadric,
GLU_SMOOTH) gluQuadricTexture(l_poQuadric,
GL_TRUE) gluSphere(l_poQuadric, 0.5, 30,
30) gluDeleteQuadric(l_poQuadric) glDisable(GL_
TEXTURE_2D)
11
Spheremap
  • Spheremap texture looks like reflection of a
    sphere projected to a plane

180
eye
90
0
12
Spheremap
  • Spheremap texture is indexed from a reflection
    vector
  • All computations are relative to the eye position
  • Texture looks like a reflection from a chrome
    hemisphere
  • All mapping is done as reflection from
    hemisphere.
  • Maps center reflects back to eyes

13
Generating Spheremap OpenGL
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILT
ER, GL_NEAREST) glTexParameteri(GL_TEXTURE_2D,
GL_TEXTURE_MAG_FILTER, GL_NEAREST) glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP) glTexGeni(G
L_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP) glEnable
(GL_TEXTURE_GEN_S) glEnable(GL_TEXTURE_GEN_T) gl
TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,
GL_DECAL) glTexParameteri(GL_TEXTURE_2D,
GL_TEXTURE_WRAP_S, GL_REPEAT) glTexParameteri(GL_
TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT) comput
eNormalsForYourObject() drawYourObject()
14
References
  • Jianxiang Dong Slides from Fall 2001
Write a Comment
User Comments (0)
About PowerShow.com