Search code examples
opengltexture-mapping

OpenGL why is the cube map warping while looking around?


Before implementing a shader cubemap I tried to make a skybox manually with six textures around it, but I get distortion while rotating.

In GL 3.3 using cubemap uniforms, is there some added math magic behind the scenes (that counteracts distortion), versus creating six flat faces and applying a texture to each side manually ?

Example
Here is a skymap using six individual textures. You can see the distortion at the cube corner as the scene rotates frame 1 frame 2 frame 3


Solution

  • After setting it up on a 3D modeling app and doing some experimentation, I feel I can answer my own question.

    Cubemaps work ONLY with first person perspective. It is important the eye/camera sits exactly at the center of the cube and the camera target orbits around. For example: Eye at center

    In the reverse scenario where the target is exactly at center and the eye orbits around it (like in a 3D modeling app) then a cubemap becomes useless by distortion. For example: target at center

    So ... to answer this question. No, there is no magic behind the GLSL cubemapping that keeps distortion from happening. It is all a matter of how the application handles its camera system.