   Reflection of other faces using GLSL
  Hi everyone!I want to write a shader, that reflects the environment including all faces around the object.First, I thought about rendering a single pixel in the fragment shader (for example with a function that gets two vectors and returns the color, you would see if you looked from the first vector to the other one), but that isn't possible with OpenGL, so the only way I know is to render the whole world to a texture and give that to the shader. But how can I do that? Or is there another way?   
  Two common ways are cubemaps or mirroring the scene. If you apply the reflection on a flat surface (water/floor/a single mirror), you can render the scene mirrored, capture it in a texture, then apply it on the surface with a shader that does projective texturing (and eventual some other tricks like distortion).If you aim for more complex stuff (like a teapot for example), you are probably best off with cubemaps. There should be plenty of tutorials, but for the info:- In a background pass, place the camera on a point in 3D space. Typically this would be the center of the object that reflects. The bigger the distance between the reflecting pixel and the cubemap camera position, the bigger the error (cubemaps won't give 100% reflections!)- After placing, aim the camera into 6 directions along the XYZ axis. For each direction, render the scene into a texture (look for FBO's, or functions to take a snapshot in case you use older hardware/OpenGL).- Now you have the surrounding scene captured in a cubeMap (which are basically 6 textures that form a cube together). You can use these for all kinds of things, including reflection/refraction shaders.- Pass your cubeMap texture to the shader. Instead of 2D texcoords, you can use direction vectors now. Depending on the pixel normal and the camera view vector onto that pixel, you can calculate a reflectionVector and use it to pick the right pixel from the cubeMap.An alternative are Dual Paraboloid maps. These only require 2 directions to capture the environment instead of 6, but also require the scene to be tesselated more. So far there aren't much other options. At least, not to get perfect reflections. There are shaders that do raycasting, but these are slow and require info about the surrounding environment, which can only be very limited. Crytek has a different approach to get glossy reflections (neither perfect) in their new engine, but that's pretty advanced stuff.Rick   