7

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?

genpfault
  • 47,669
  • 9
  • 68
  • 119
Albus Dumbledore
  • 11,500
  • 22
  • 60
  • 102
  • 2
    -1: You don't need us to confirm what the specification says. What the specification says is how it works. – Nicol Bolas Aug 08 '11 at 10:30
  • I am not sure whether I am interpreting it rightly :-) – Albus Dumbledore Aug 08 '11 at 10:35
  • 3
    Though I must say that I don't understand why this warrants a downvote for the question, having seen many questions that were a lot worse than this one. The question "shows research effort" and is "clear". It's not terribly useful _to me_, but quite possibly to someone else (someone who might wonder "how the heck does this work" too). Which makes me wonder if it's not legitimate to ask whether one understands the wording correctly? – Damon Aug 08 '11 at 10:48
  • My point is that the spec's language is pretty unambiguous in this regard. It says, "At texture application time, the interpolated per-fragment direction vector selects one of the cube map face’s two-dimensional images based on the largest magnitude coordinate direction (the major axis direction)." There is really no other way to read that. It even has a table at the top of the page showing very clearly how texture coordinates map to cube map faces. – Nicol Bolas Aug 08 '11 at 11:20
  • I never saw the table (my mistake). It does provide an unambiguous way to select the face. Sorry then. – Albus Dumbledore Aug 08 '11 at 12:21

1 Answers1

5

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

datenwolf
  • 149,702
  • 12
  • 167
  • 273