Stage3D 剔除混乱
在 OpenGL 中,默认设置是:
- 坐标系 = 右手,
+x->right,+y->up,+z->towards-viewer
。 - 因此,绕 z 的正旋转会将 x 基向量移动到 y(逆时针)。
- 正面多边形被定义为 CCW 顶点。
- 背面的剔除是通过以下方式实现的:
glEnable(GL_CULL_FACE); glCullFace(GL_BACK);
好吧,我们都知道这一点。在 Flash 11/Molehill/Stage3d
中,默认值应该是相同的。
但是,如果我在步骤 4 中通过以下方式启用背面剔除:
c3d.setCulling(Context3DTriangleFace.BACK);
我的面部将被剔除。看来默认值是Context3DTriangleFace.FRONT。我在 OpenGL 和 Stage3D 中创建了一个健全性检查案例,它们在其他方面是相同的。相同的顶点/索引列表,保留默认值,相同的正交投影矩阵,身份模型视图,但我必须将剔除设置为前面而不是后面。
就好像 Stage3D 有不同的绕线默认值。即,就好像在幕后,OpenGL 已被设置为: glFrontFace(GL_CW); 而不是 OpenGL 默认值: glFrontFace(GL_CCW);
还有其他人遇到过这个吗?这让我抓狂...
In OpenGL, the default setup is:
- Co-ordinate system = right handed, with
+x->right, +y->up, +z->towards-viewer
. - Therefore, a postive rotation around z will move the x basis vector to y (anti-clockwise).
- Front-facing polygons are defined as CCW vertices.
- Culling of backface faces is achieved by:
glEnable(GL_CULL_FACE); glCullFace(GL_BACK);
Ok, we all know this. In Flash 11/Molehill/Stage3d
, the defaults are supposed to be the same.
However, if I enable backface culling in step 4 via:
c3d.setCulling(Context3DTriangleFace.BACK);
my faces are culled. It seems the default is Context3DTriangleFace.FRONT. I created a sanity-check case in OpenGL and Stage3D which are otherwise identical. Same vertex/index list, leave defaults, same orthographic projection matrix, identity ModelView, yet I have to set culling to FRONT not BACK.
It's as if Stage3D has a different winding default. i.e. it's as if, under the hood, OpengGL has been set to:
glFrontFace(GL_CW);
instead of OpenGLs default:
glFrontFace(GL_CCW);
Has anyone else come across this? It's driving me nuts...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
很久以前就想回答这个问题了,但是忘记了,所以现在就回答一下。
我是对的,Stage3D 认为正面是屏幕空间中的 CW 缠绕,而不是 OpenGL 的 CCW。我希望这对所有使用 OpenGL 的人有所帮助。只需颠倒索引缓冲区索引的顺序,或将剔除模式更改为 FRONT 即可。我决定更改索引顺序。
干杯,
谢恩
I meant to answer this ages ago, but forgot, so I'll just answer it now.
I was right, Stage3D considers front-facing to be a CW winding in screen-space, as opposed to OpenGL's CCW. I hope this helps anyone coming from OpenGL. Just reverse the order of your index buffer indices, or change the culling mode to FRONT. I decided to change the index order.
Cheers,
Shane
也许一个的正面是顺时针方向的,另一个是逆时针方向的。
glFrontFace(GL_CW);
或glFrontFace(GL_CCW);
Perhaps one has a front face clockwise and the other counter-clockwise.
glFrontFace(GL_CW);
orglFrontFace(GL_CCW);