Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selecting the face of a Cubemap in GLSL

Ok, I'm trying to understand how the face of a cubemap is selected using the coordinates supplied to textureCube(). From the spec, I gather the coord with the biggest magnitude defines the face.

For example these coords (-0.2, 0.7, 0.65) would select the Y+ face of the cube map, but these (0.2, 0.3, -0.8) would select the Z- face.

Am I right in my understanding?

like image 979
Albus Dumbledore Avatar asked Aug 08 '11 10:08

Albus Dumbledore


People also ask

What is a texture cube?

A Cubemap Texture is a texture, where each mipmap level consists of six 2D images which must be square. The 6 images represent the faces of a cube. The texture coordinate used to access a cubemap is a 3D direction vector which represents a direction from the center of the cube to the value to be accessed.

What is a cube map used for?

Cube maps provide a fairly straightforward and efficient solution to rendering stable specular highlights. Multiple specular highlights can be encoded into a cube map texture, which can then be accessed by interpolating across the surface's reflection vector to supply coordinates.

What is cubemap reflection?

Specular Indirect Lighting is stored in an array of cubemaps. These are defined by the Reflection Cubemap objects. They specify where to sample the scene's lighting and where to apply it.


1 Answers

Indeed you are. This is the simplemost way to select the face of a cube, given a direction from the center.

like image 154
datenwolf Avatar answered Oct 03 '22 19:10

datenwolf