# Panorama from cube map without geometry

Is it possible to achieve effect equivalent to looking on the cube textured from cube map from its center, but without creation of its faces (6 quads or 12 triangles)?

Say, one needed a skybox, but without the "box". There is no anything except skybox and there is no need to calculate depth of something - all the points of that skybox are always visible.

• – msell Oct 19 '17 at 6:39

It's very easy to do this. Cube maps only need a 3d vector pointing in the looking direction. You can generate this in the shader.

What you'll need to provide as uniforms are the aspect ratio, the FOV and the cube map. You need to render a quad that fills the whole screen and give it the usual texture coordinates between 0 and 1.

First of all, let's generate the x coordinate of the vector. You need to take the u coordinate of the texture coordinates, subtract 0.5 and multiply it by aspect ratio * FOV, then put this into the cosinus function:

x = cos((u - 0.5) * aspectRatio * FOV)


The y is almost the same thing, but you won't need to multiply by the aspect ratio and you'll need to use sinus:

y = sin((v - 0.5) * FOV)


Now z should make this vector a unit vector, so x^2 + y^2 + z^2 should equal 1, so z is

z = √(1 - x^2 - y^2)


And that's the vector you need to provide to the cubemap. If you want to rotate it, then simply use a rotation matrix (if you have a 4x4 transformation matrix, then just clip it to 3x3 and use that).

However, there's absolutely no reason to use this over a simple box. 8 vertices and 36 indicies isn't much