Original Post
Hi, I'm having some trouble implementing bump mapping. I'll give you some background on what I'm trying to do and what is happening. An image is being stored in a pointer for the color map I want to use for the object. I then switch to the second texture unit so I can do this in one pass. The pointer now has the info for the normal map. The tex coords are being passed to GLSL with the MultiTex call so when I'm in the vertex shader I assign the gl_TexCoord[0] to MultiTexCoord0 and gl_TexCoord[1] to MultiTexCoord1. In the frag shader I use the 2D sampler but the second texture just has the values for the first one. Here's my code relevant to the texturing, please help: GLSL in vert shader: gl_TexCoord[0] = gl_MultiTexCoord0; //color map gl_TexCoord[1] = gl_MultiTexCoord1; //normal map in frag shader: vec4 cMap = texture2D(ColorMap, vec2(gl_TexCoord[0])); //cMap is float rgb values of texture vec4 nMap = texture2D(NormalMap, vec2(gl_TexCoord[1])); //nMap is float rgb values of texture C++ in main //texture is GLubyte [256][256][3] and has data by this point // allocate a texture name glGenTextures( 2, textureNum ); //global GLuint textureNum[2]; glActiveTexture(GL_TEXTURE0); //activate texture unit 1 // select our current texture glBindTexture( GL_TEXTURE_2D, textureNum[0] ); glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); // when texture area is small, bilinear filter the closest mipmap glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST ); // when texture area is large, bilinear filter the original glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); // the texture wraps over at the edges (repeat) glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); // build our texture mipmaps gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, imagewidth, imageheight, GL_RGB, GL_UNSIGNED_BYTE, texture ); glActiveTexture(GL_TEXTURE1); glBindTexture( GL_TEXTURE_2D, textureNum[1] ); glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); // when texture area is small, bilinear filter the closest mipmap glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST ); // when texture area is large, bilinear filter the original glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); // the texture wraps over at the edges (repeat) glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); HeighttoNormalMap(); //texture is changed to store the normal map now gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, imagewidth, imageheight, GL_RGB, GL_UNSIGNED_BYTE, texture ); in display //I have three objects I draw but they all follow this format glActiveTexture(GL_TEXTURE0); //do I need to call bindTexture for each texture unit? glEnable( GL_TEXTURE_2D ); glActiveTexture(GL_TEXTURE1); glEnable( GL_TEXTURE_2D ); glColor3f(1.0f, 1.0f, 1.0f); for(int i = 0; i < FaceList[0]->numFaces; i++){ //goes through each face glBegin(GL_POLYGON); for(int j = 0; j < FaceList->numVerts; j++){ //goes through each vertex float u = ...; //is defined here but is long and not the problem float v = ...; // same here glMultiTexCoord2f(GL_TEXTURE0, u, v); glMultiTexCoord2f(GL_TEXTURE1, u, v); glVertex3f(//same here); } glEnd(); } glActiveTexture(GL_TEXTURE0); glDisable( GL_TEXTURE_2D ); glActiveTexture(GL_TEXTURE1); glDisable( GL_TEXTURE_2D ); }