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

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

问题描述

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

  ________ 
| |
| pos y |
| |
_______ | ________ | _________________
| | | | |
| neg x | pos z | pos x | neg z |
| | | | |
| _______ | ________ | ________ | ________ |
| |
| |
| neg y |
| ________ |


解决方案


错误的Y,所以我必须反转正面Y与负面Y面。为什么?

是的,这是Cube Maps最奇怪的事情之一。放心吧,你并不是唯一一个为此付出的人。您会发现:

立方体贴图被指定为遵循RenderMan规范(无论出于何种原因),并且RenderMan假定图像的原点位于左上角,与通常OpenGL行为的图像来源在左下角。这就是事情在Y方向交换的原因。它完全违背了通常的OpenGL语义,根本没有意义。但现在我们一直坚持下去。



请注意左上角与左下角是在从模型空间到NDC的身份转换的上下文中定义的空间


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

解决方案

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

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

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