Computer Graphics glTexCoord2f glTexCoord2f 00 10 11 01 glTexCoord2f 00 120 1212 012 glGenTextures 1 amp texname ID: 297319
Download Presentation The PPT/PDF document "TEXTURES & OTHER GOODIES" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
TEXTURES & OTHER GOODIES
Computer GraphicsSlide2
glTexCoord2f(...);
+
=Slide3
glTexCoord2f(...);
+
(0,0)
(1,0)
(1,1)
(0,1)
=Slide4
glTexCoord2f(...);
+
(0,0)
(1/2,0)
(1/2,1/2)
(0,1/2)
=Slide5
glGenTextures(1, &
texname); // Generate texture namesglPixelStorei
(GL_UNPACK_ALIGNMENT, 1);
// Set pixel storage modes
glBindTexture
(GL_TEXTURE_2D,
texname); // Bind a texture to a texturing target// Build a 2D mipmap - builds a series of pre-filtered 2D texture maps of decreasing resolutionsgluBuild2DMipmaps(GL_TEXTURE_2D, 4, GL_RGBA, GL_UNSIGNED_BYTE, image->
getPixels() );// Set texture parametersglTexParameteri(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);
// Use GL_MODULATE for standard texturing
// GL_DECAL for unlightedness// GL_BLEND for interaction with a background color using the alpha channel of image// GL_REPLACE to completely disregard lighting and replace it with actual colors from the texture imageglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
All this done for you!Slide6
glBindTexture(GL_TEXTURE_2D, tex1);
// tex1 is the identifier for the image you are trying to map on a quadglBegin(GL_POLYGON);
glTexCoord2f(0.0, 0.0);
glVertex3f(-5, -5, 4);
glNormal3f(0, 0, 1);
glTexCoord2f(1.0, 0.0); glVertex3f(5, -5, 4); glNormal3f(0, 0, 1);glTexCoord2f(1.0, 1.0); glVertex3f(5, 5, 4); glNormal3f(0, 0, 1);glTexCoord2f(0.0, 1.0); glVertex3f(-5, 5, 4); glNormal3f(0, 0, 1);glEnd();Slide7
(0, 0)
(1, 0)
(1, 1)
(0, 1)
+
(-5, -5, 4)
(5, -5, 4)
(5, 5, 4)
(-5, 5, 4)
World coordinates
Texture coordinates
=Slide8Slide9
TEXTURING EXAMPLESSimple image loaderTexturing exampleSlide10
Advance Texturing TechniquesMaking things look wicked awesome!!!Slide11
LIGHTMAPS
+
=Slide12Slide13
BUMPMAPSSlide14
Normal Maps
+
=Slide15
Displacement MapsSlide16
TERRAINS: SKYBOXSlide17Slide18Slide19
ASSIGNMENTDownload ‘PlanetTextures’ zip fileContains textures for various planetsDownload ‘texturesOnQuadObjects’ zip fileShows how to do texturing on various quadratic objectsNow, add textures to your planets to make it look more realisticDownload ‘skyboxTextures’ zip file
Now, put your solar system in a skyboxInsulate translations and scaling on the skybox. Only allow rotations. Why?Slide20
ADDITIONAL GOODIESNormalVector.zipCalculates normal vector, given three verticesOpenGLFontRender.zipWrite text using OpenGL fontsSimpleImageLoader.zipSimple illustration for loading textures
TexturingExample.zipVarious things you can do with texture mapping