Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convention of faces in OpenGL cubemapping

What is the convention OpenGL follows for cubemaps?

I followed this convention (found on a website) and used the correspondent GLenum to specify the 6 faces GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT but I always get wrong Y, so I have to invert Positive Y with Negative Y face. Why?

          ________
         |        |
         | pos y  |
         |        |
  _______|________|_________________
 |       |        |        |        |
 | neg x | pos z  |  pos x |  neg z |
 |       |        |        |        |
 |_______|________|________|________|
         |        |
         |        |
         | neg y  |
         |________|
like image 799
linello Avatar asked Jul 27 '12 10:07

linello


People also ask

How do you make a textured cubemap?

Select Assets > Create > Legacy > Cubemap from the menu, and drag six textures into empty slots in the inspector. Textures for the corresponding cubemap face. Width and Height of each Cubemap face in pixels. The textures will be scaled automatically to fit this size.

What does a cubemap do?

A cubemap is a texture that represents a three-dimensional rendering of an area. The Source Engine uses env_cubemap entities as sampling points to generate these textures, which are then automatically embedded into the map file.

How many coordinates are needed when getting a sample from a cube texture?

When specifying your texture coordinates, you will then use sets of 3 coordinates instead of sets of 2. In a simple cube, you point to the 8 corners using normalized vectors.


2 Answers

but I always get wrong Y, so I have to invert Positive Y with Negative Y face. Why?

Ah, yes, this is one of the most odd things about Cube Maps. Rest assured, you're not the only one to fall for it. You see:

Cube Maps have been specified to follow the RenderMan specification (for whatever reason), and RenderMan assumes the images' origin being in the upper left, contrary to the usual OpenGL behaviour of having the image origin in the lower left. That's why things get swapped in the Y direction. It totally breaks with the usual OpenGL semantics and doesn't make sense at all. But now we're stuck with it.

Take note that upper left, vs. lower left are defined in the context of identity transformation from model space to NDC space

like image 68
datenwolf Avatar answered Sep 24 '22 10:09

datenwolf


Here is a convenient diagram showing how the axes work in OpenGL cubemaps:

enter image description here

like image 45
Nicol Bolas Avatar answered Sep 24 '22 10:09

Nicol Bolas