Presentation is loading. Please wait.

Presentation is loading. Please wait.

Texture Mapping. Introduction What is Texture Mapping? Types of Texture Mapping –1D, 2D and 3D SDL and OpenGL.

Similar presentations


Presentation on theme: "Texture Mapping. Introduction What is Texture Mapping? Types of Texture Mapping –1D, 2D and 3D SDL and OpenGL."— Presentation transcript:

1 Texture Mapping

2 Introduction What is Texture Mapping? Types of Texture Mapping –1D, 2D and 3D SDL and OpenGL

3 Getting Your Feet Wet Five Steps in Getting Texture Mapping to Work –1. Load the Bitmap –2. Generate the Texture Handle –3. Bind and Configure –4. Build Texture in OpenGL –5. Bind and Use

4 A Little More Detail 1. Load Bitmap 2. Generate a Texture Handle –glGenTextures(1, &temptex); 3. Bind and Configure –glBindTexture (GL_TEXTURE_2D, nNewTextureID); –glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); –glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); –glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); –glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 4. Build the Texture in OpenGL –gluBuild2DMipmaps (GL_TEXTURE_2D, nBPP, nWidth, nHeight, –(nBPP == 3 ? GL_RGB : GL_RGBA),GL_UNSIGNED_BYTE, –pData);

5 In Depth Discussion The Bitmap File Format –File Header Size and Type of File –Info Header Image dimensions Bits per Pixel (BPP) –Image Data(unsigned char) What can be used as a Texture?

6 In Depth Discussion Texture Handle Generation –glGenTextures(1, &temptex); –GL_TEXTURE_1D and GL_TEXTURE_3D Texture Binding –glBindTexture (GL_TEXTURE_2D, TextureID); Environment Settings –glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); –GL_DECAL and GL_BLEND

7 In Depth Discussion Texture Wrapping Parameters –glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); –glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); –Also GL_CLAMP

8 In Depth Discussion Texture Resizing Filters –glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST) –GL_LINEAR, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_NEAREST, and GL_LINEAR_MIPMAP_LINEAR –glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST) –GL_LINEAR

9 In Depth Discussion What are Mipmaps? Building the Texture –gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, width, height, GL_RGB, GL_UNSIGNED_BYTE, data) Using the Texture –glTexCoord2f(0.0, 1.0); glVertex3i(-1, 1, 1)

10 Texture and Lighting Four Steps for Lighting –Calculate Normals –Position Light –Choose Shading Model –Set Material Setting Materials –glMaterialfv(GL_FRONT, GL_AMBIENT, matAmbient) –glMaterialfv(GL_FRONT, GL_DIFFUSE, matDiffuse)

11 Texture Transparency The Blending Function –glEnable(GL_BLEND); –glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); –glColor4f(1.0f, 1.0f, 1.0f, 0.5) Depth Testing Issues

12 Playing with Texture Coordinates Easy as Pie Take your original Texture coordinates and move them around Use Texture Coordinates to only show part of the image Textured Fonts

13 Multi-Pass Multi-Texturing What is Multi-Texturing Why not Single Pass Multi-Texturing How to do Multi-Pass Multi-Texturing –1. Draw your object with base texture –2. Draw your object again with blended texture –3. Repeat step 2 till satisfied

14 Advanced Topics Other uses of Texture Mapping –Imposters –Lightmapping –Shadowmapping –Environment Mapping –Projective Texturing Procedural Texture Generation


Download ppt "Texture Mapping. Introduction What is Texture Mapping? Types of Texture Mapping –1D, 2D and 3D SDL and OpenGL."

Similar presentations


Ads by Google