Presentation is loading. Please wait.

Presentation is loading. Please wait.

October 9, 2002Serguei A. Mokhov, 1 COMP471 – Computer Graphics OpenGL: Texture Mapping.

Similar presentations


Presentation on theme: "October 9, 2002Serguei A. Mokhov, 1 COMP471 – Computer Graphics OpenGL: Texture Mapping."— Presentation transcript:

1 October 9, 2002Serguei A. Mokhov, mokhov@cs.concordia.ca 1 COMP471 – Computer Graphics OpenGL: Texture Mapping

2 October 9, 2002Serguei A. Mokhov, mokhov@cs.concordia.ca 2 The “Need” Create complex appearance w/o much computational effort

3 October 9, 2002Serguei A. Mokhov, mokhov@cs.concordia.ca 3 Texture Def A detailed pattern repeated many times to tile a given plane A multidimensional image mapped to a multidim. space.

4 October 9, 2002Serguei A. Mokhov, mokhov@cs.concordia.ca 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 October 9, 2002Serguei A. Mokhov, mokhov@cs.concordia.ca 5 Viewing 2D Texture Space 3D Model Space 2D Screen Space parameterization projection compound mapping

6 October 9, 2002Serguei A. Mokhov, mokhov@cs.concordia.ca 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 October 9, 2002Serguei A. Mokhov, mokhov@cs.concordia.ca 7 Reading Textures readAllTextures()

8 October 9, 2002Serguei A. Mokhov, mokhov@cs.concordia.ca 8 Mapping Texture on Flat Surfaces and Quadric Objects Cube Sphere Spheremap

9 October 9, 2002Serguei A. Mokhov, mokhov@cs.concordia.ca 9 Cube glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, m_aiTexNames[p_iFaceColor]); … draw cube’s face … glDisable(GL_TEXTURE_2D);

10 October 9, 2002Serguei A. Mokhov, mokhov@cs.concordia.ca 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 October 9, 2002Serguei A. Mokhov, mokhov@cs.concordia.ca 11 Spheremap Spheremap texture looks like reflection of a sphere projected to a plane eye 0 90 180

12 October 9, 2002Serguei A. Mokhov, mokhov@cs.concordia.ca 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. Map’s center reflects back to eyes

13 October 9, 2002Serguei A. Mokhov, mokhov@cs.concordia.ca 13 Generating Spheremap: OpenGL glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); glTexEnvi(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); computeNormalsForYourObject(); drawYourObject();

14 October 9, 2002Serguei A. Mokhov, mokhov@cs.concordia.ca 14 References Jianxiang Dong Slides from Fall 2001


Download ppt "October 9, 2002Serguei A. Mokhov, 1 COMP471 – Computer Graphics OpenGL: Texture Mapping."

Similar presentations


Ads by Google