   [GLSL] Reflective Cubemap
  Hello everyone, first time posting here. I'm also extremely new to GLSL.I'm working on creating a reflective cubemap in GLSL (creating an environment from the cube, with some reflective object inside it), and I'm not sure what I'm doing wrong. So far everything I've done is based on various online tutorials - I think that I'm either not calculating the reflection vector correctly or possibly my textures just aren't being loaded (although I'm not getting any errors). Here is the relevant code:In my init function:I'm a little unsure if I'm doing the glTexImage2D part right. I'm letting the compiler decide what size to use for the textures, but I'm not sure exactly how it does that. The .bmp images are 500px X 500px.glEnable(GL_TEXTURE_CUBE_MAP); AUX_RGBImageRec *TextureImage[6];memset(TextureImage,0,sizeof(void *)*6);TextureImage[0]=LoadBMP("positiveX.bmp");TextureImage[1]=LoadBMP("negativeX.bmp");TextureImage[2]=LoadBMP("positiveY.bmp");TextureImage[3]=LoadBMP("negativeY.bmp");TextureImage[4]=LoadBMP("positiveZ.bmp");TextureImage[5]=LoadBMP("negativeZ.bmp");glGenTextures(6, &texture[0]);glBindTexture(GL_TEXTURE_CUBE_MAP, texture[0]);glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_REPEAT);glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_REPEAT);glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_REPEAT);glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER,GL_LINEAR);glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER,GL_LINEAR);glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE, GL_REPLACE); for(int i=0; i<6; i++){glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+i, 0, GL_RGB,TextureImage->sizeX, TextureImage->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage->data);}//compiling, linking, shaders, etcGLint loc;loc = glGetUniformLocationARB(g_programObj, "envMap");glUniform1iARB(loc, 0);Relevant part of my display callback:glUseProgramObjectARB( g_programObj );  glFrontFace(GL_CW);  glutSolidTeapot(1);  glFrontFace(GL_CCW); glUseProgramObjectARB( NULL );Vertex Shader:varying vec3 normal;varying vec4 vert;varying vec3 reflectDir;void main( void ){gl_Position = ftransform(); vert = gl_ModelViewMatrix * gl_Vertex;normal = normalize(gl_NormalMatrix * gl_Normal);vec3 eyeDir = vert.xyz;reflectDir = reflect(eyeDir, normal); // Not sure if this is right}Fragment Shader:varying vec3 normal;varying vec4 vert;varying vec3 reflectDir;uniform samplerCube envMap;void main( void ){    vec3 envColor = vec3(textureCube(envMap, normalize(reflectDir)));    const vec3 viewpos = vec3(0.0, 0.0, 1.0);    const vec3 lightpos = vec3(10.0, 10.0, 10.0);   vec3 V = normalize(viewpos - vert.xyz);    vec3 L = normalize(lightpos - vert.xyz);    const float ambient_intensity   = 0.5;    const float light_intensity= 1.0; vec3 ambient;    vec3 diffuse;    vec3 specular;    float shininess;//Silver   ambient  =  vec3(0.19225, 0.19225, 0.19225);   diffuse  =  vec3(0.50754, 0.50754, 0.50754);   specular =  vec3(0.508273, 0.508273, 0.508273);   shininess = 51.2;vec3 norm = normalize(normal);vec3 halfAngle = normalize (L + V);//ambient term;vec3 ambient_term =  ambient_intensity * ambient;//diffuse term:float NdotL = dot(L, norm);vec3 diffuse_term = light_intensity * NdotL * diffuse;//specular term:float facing = NdotL > 0.0 ? 1.0:0.0;float NdotH = clamp(dot(halfAngle, norm), 0.0, 1.0);vec3 specular_term = light_intensity * facing * pow(NdotH, shininess) * specular;//add three terms together:vec3 result = ambient_term + diffuse_term + specular_term;envColor = mix(envColor, vec3(result), .9);gl_FragColor = vec4(envColor, 1.0);}The intent in the fragment shader is to create a silver object (a teapot in this case), then mix that with the environment color, based on the cube map. I end up with just a silver teapot, no reflection effect.If I turn only use the original env color (I don't mix it with the silver illumination model, which I think should create a purely mirror-like object), I just get black.Any ideas as to what I may be doing wrong here? I can post more source code if I've left anything relevant out.   
  I'm not that sure about GLSL (since I use CG for shaders) but at a first glance I could spot 2 possible sources for your error:1. Where do you bind the cubemap for use with the shader (something like glBindTexture(GL_TEXTURE_2D, Texture); )?2. Maybe your driver doesn't support non-power-of-two textures. Which OpenGL version are you using? Is the NPOT extension supported (I don't remember the exact name)?   ;Quote:Original post by Lord_EvilI'm not that sure about GLSL (since I use CG for shaders) but at a first glance I could spot 2 possible sources for your error:1. Where do you bind the cubemap for use with the shader (something like glBindTexture(GL_TEXTURE_2D, Texture); )?2. Maybe your driver doesn't support non-power-of-two textures. Which OpenGL version are you using? Is the NPOT extension supported (I don't remember the exact name)?I'm binding the texture in my init function:glBindTexture(GL_TEXTURE_CUBE_MAP, texture[0]);texture[] is a gluint array of size 6.I believe I'm using openGL 1.1.Also my hardware is fairly new, if that's any indication of what it would support. I'm not sure how to check.   ;  On a whim I changed my images to be 256x256 (power of 2 rather than just 500) and it worked!Well, semi-worked...but at least I'm seeing something!  Woot!   ;  You can check your OpenGL version by querying the version string.Alternatively you can use GLEW's visualinfo application which generates a text report (or, if you are on Linux, glxinfo).If you have some recent NVidia or ATI hardware and Windows your driver most certainly supports OpenGL 2.x or even 3.x, especially since you're able to use shaders which is a clear indication of OpenGL 1.5+.   