OpenGL 立方体映射中的面约定 [英] Convention of faces in OpenGL cubemapping

查看:37
本文介绍了OpenGL 立方体映射中的面约定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OpenGL 对立方体贴图遵循的约定是什么?

What is the convention OpenGL follows for cubemaps?

我遵循了这个约定(在网站上找到)并使用通讯员 GLenum 来指定 6 个面 GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 但我总是得到错误的 Y,所以我必须用负 Y 面反转正 Y.为什么?

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  |
         |________|

推荐答案

但我总是弄错 Y,所以我必须用负 Y 面反转正 Y.为什么?

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

啊,是的,这是 Cube Maps 最奇怪的事情之一.请放心,您不是唯一一个爱上它的人.你看:

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:

立方体贴图已被指定为遵循 RenderMan 规范(无论出于何种原因),RenderMan 假设图像的原点位于左上角,这与将图像原点位于左下角的 OpenGL 常规行为相反.这就是事物在 Y 方向上交换的原因.它完全打破了通常的 OpenGL 语义,完全没有意义.但现在我们坚持了下来.

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.

注意左上角和左下角是在从模型空间到 NDC 空间的恒等变换上下文中定义的

这篇关于OpenGL 立方体映射中的面约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆