   glsl Mirroring
  I've been able to set up a cube that can mirror the environment but I came to find that most tutorials and such don't explain very how to make it dynamic. It seems like most of use doing this for the first time have this problem of moving the camera around and having the reflections in the correct spot. I've googled this and there are too many different answers that seem too different at the same time especially since it seems that everyone of those set up there cubemap differently. So finally I've come to ask the people of the forum what I'm doing wrong here.I set up my cubemap like so (the idea came from "beginning opengl" book)://My "up" in the world is Z-Axis though I do it this wayconst float envVec[6][6] = { 1,  0,  0,0,  1,  0, //pos_x   -1,  0,  0,0,  1,  0, //neg_x    0,  1,  0,0,  0, -1, //pos_y    0, -1,  0,0,  0,  1, //neg_y    0,  0,  1,0,  1,  0, //pos_z    0,  0, -1,0,  1,  0};//neg_zvoid updateReflection(){    ///etc...    ///Set CubeMap Images    for(int i=0; i<6; i++)    {   glLoadIdentity();   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);   glPushMatrix();   gluLookAt(0, 0, 0, envVec[0], envVec[1], envVec[2], envVec[3], envVec[4], envVec[5]);   drawObjects();   if(!cIsInited)  glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+i, 0, GL_RGBA, 0, 0, reflectMapSize, reflectMapSize, 0);   else  glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+i, 0, 0, 0, 0, 0, reflectMapSize, reflectMapSize);   glPopMatrix();    }    //etc...}Vertex Shader:uniform vec3 eyePosition; //camera positionvarying vec3 reflectDir;varying float lightInt;void main(){gl_Position = ftransform();vec3 normal= gl_Normal;vec3 eyeDir= -eyePosition.xyz + gl_Vertex.xyz;reflectDir= reflect(eyeDir, normal);lightInt= max(0.0, dot(normal, normalize(gl_LightSource[0].position.xyz - pos.xyz)));}Fragment Shader:uniform samplerCube envMap;varying vec3 reflectDir;varying float lightInt;void main(){vec3 envColor= vec3(textureCube(envMap, reflectDir));vec3 baseColor= vec3(0.0, 0.0, 0.0);float mixRatio= 0.5;vec3 base= lightInt * baseColor;envColor= mix(envColor, base, mixRatio);gl_FragColor= vec4(envColor, 1.0);}It seems to show the results I want though If I move the camera wouldn't the reflection teem to shift a little and what I'm doing only works for a cube unless I have to change the cubemap every time for a different object?I've read posts about using the world matrix instead and I've seen other mess with the textureMatrix. It just made the situation more confusing.[Edited by - Asem on June 26, 2009 12:51:32 AM]
  I'm bumping this because I really am stuck and if I didn't explain it very clearly sorry about that. I tried asking simpler questions to solve this myself like the world matrix thing since I've found that it and the view are combined and was trying to be sure of the way they were to be separated.Technically what I have works but only for the cube if I want the reflections to be correct for a sphere it requires me to change the parameters for envVec to match up correctly. There has to be a way to not have to set it manually for each object and I don't think I should have to if I do it correctly but I'm missing something and I just don't get it.   