I wrote a program to implement DOT3 bump mapping. It uses a normalization cubic map and a bump map. The program works flawlessly on my desktop with NVidia Geforce Ti 4200. However on my Sager laptop with ATI mobolity Radeon 9000, although I can see the bumps, the diffuse lighting effects are incorrect. I am currently using Omega 5.1 driver on my laptop. I suspect it has something to do with how ATI card handles cubic maps. Here is part of my code to generate normalization cube maps:
GLuint create_normalization_cube_map(int size)
{
GLuint tex_cube_map;
GLfloat *image_buffer;
int buffer_size;
GLenum target[6]={
GL_TEXTURE_CUBE_MAP_POSITIVE_X,
GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
};
int i, j, k, counter;
// Create temporary image buffer
buffer_size=4*size*size;
image_buffer=new GLfloat [buffer_size];
for (i=0; i<buffer_size; ++i)
{
if (i%4==3) image_buffer[i]=1.0;
else image_buffer[i]=0.0;
}
// Generate texture object and set texture parameters
glGenTextures(1, &tex_cube_map);
glBindTexture(GL_TEXTURE_CUBE_MAP, tex_cube_map);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
// Create each of the six faces of the cube map
for (i=0; i<6; ++i)
{
float s, t, r[3];
// s, t: texture coordinates
// r[3]: normalized direction vector
counter=0;
for (j=0; j<size; ++j)
{
t=(float)j/(float)size;
t=2.0*t-1.0;
for (k=0; k<size; ++k)
{
s=(float)k/(float)size;
s=2.0*s-1.0;
// Obtain direction vector
switch (i)
{
case 0://+x
r[0]=1.0; r[1]=-t; r[2]=-s;break;
case 1://-x
r[0]=-1.0; r[1]=-t; r[2]=s;break;
case 2://+y
r[0]=s; r[1]=1.0; r[2]=t;break;
case 3://-y
r[0]=s; r[1]=-1.0; r[2]=-t;break;
case 4://+z
r[0]=s; r[1]=-t; r[2]=1.0;break;
case 5://-z
r[0]=-s; r[1]=-t; r[2]=-1.0;break;
}
// Normalize direction vector and store it
// as color values in cube map texture
float ftmp=sqrt(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]);
ftmp=1.0/ftmp;
for (int kk=0; kk<3; ++kk)
{
r[kk]*=ftmp;
r[kk]=0.5*(r[kk]+1.0);
image_buffer[counter+kk]=r[kk];
}
counter+=4;
}
}
// Specify one face of the cube map texture
glTexImage2D(target[i], 0, GL_RGBA, size, size, 0,
GL_RGBA, GL_FLOAT, image_buffer);
}
delete [] image_buffer;
return tex_cube_map;
}
Any help would be appreciated.