I have recently switched over the VBO’s and have implemented Multitexturing.
I have just tried adding Dot3 bump mapping using other extensions and all I see now is black, unless I change the texture environment variables, then I see purple or a green that fades to red.
The code for the bump mapping works perfectly using normal glVertex3f and glMultiTexCoord3fARB calls:
vertex_position = get_vec3( ((float)mapX+LOD)/(float)MapWidth, Height, (float)mapZ/(float)MapHeight);
vertex_to_light[0] = light_position[0] - vertex_position[0];
vertex_to_light[1] = light_position[1] - vertex_position[1];
vertex_to_light[2] = light_position[2] - vertex_position[2];
glMultiTexCoord3fARB(GL_TEXTURE0_ARB, vertex_to_light[0], vertex_to_light[1], vertex_to_light[2]);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, (float)mapX/(float)MapWidth, ((float)mapZ)/(float)MapHeight);
glMultiTexCoord2fARB(GL_TEXTURE2_ARB, (float)mapX/(float)MapWidth, ((float)mapZ)/(float)MapHeight);
glMultiTexCoord2fARB(GL_TEXTURE3_ARB, 0, 0);
glVertex3f(mapX*scale*3,Height*scaleheight,mapZ*scale);
I am using the same code in the VBO version to create the normalisation cube map and the code for implementing it is as:
glActiveTextureARB(GL_TEXTURE0);
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, normalization_cube_map);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE) ;
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE) ;
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBOTexCoordsNorm );
glTexCoordPointer( 3, GL_FLOAT, 0, (char *) NULL );
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glActiveTextureARB(GL_TEXTURE1);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[tGNormalMap]);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_DOT3_RGB) ;
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS) ;
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE) ;
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBOTexCoordsGround );
glTexCoordPointer( 2, GL_FLOAT, 0, (char *) NULL );
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glActiveTextureARB(GL_TEXTURE2);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[tGround]);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBOTexCoordsGround );
glTexCoordPointer( 2, GL_FLOAT, 0, (char *) NULL );
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glActiveTextureARB(GL_TEXTURE3);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[tGDetailMap]);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2);
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBOTexCoordsGround );
glTexCoordPointer( 2, GL_FLOAT, 0, (char *) NULL );
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
Followed by the required glDisable calls after the drawing.
The only difference is that the texture coordinates for the VBO normalisation cube map is generated at run time with all the other vertex and texture coordinates while in the old version, it sets the coordinates in real time, during the code to create my object.
Can anyone tell me what is wrong with this for it to not work…
I have been trying to find what is wrong since last night and it is really frustrating, especially when other people code that I find, looks similar to mine, but still does not work.
The code I am using to create the normalisation map is the code on NeHe, if that helps.