Opengl 镜像变换背面剔除

发布于 2024-09-29 01:10:56 字数 115 浏览 1 评论 0原文

在 openGL 中,我有一个沿轴缩放 -1 的对象...这会导致该对象无法正确渲染,因为所有正面现在都是背面。如果不禁用剔除,我该如何让这个对象正确渲染?有没有办法在不修改构成模型的纹理法线顶点的情况下做到这一点?

In openGL, I've got an object that I scale by -1 along an axis... this results in the object not rendering properly because all the front faces are now back faces. Short of disabling culling, how would I get this object to render right? Is there a way to do it without modifying the textured normal vertices that make up my model?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

第七度阳光i 2024-10-06 01:10:56

您可以简单地切换剔除模式。您可以使用glCullFace(mode)来决定应剔除哪些三角形。提供 GL_BACK 参数表示仅渲染正面多边形,而提供 GL_FRONT 参数表示仅渲染背面多边形。因此,如果您的转换意味着“背面”多边形实际上是正面,则调用 glCullFace(GL_FRONT) 应该可以解决问题。

作为替代方案,您还可以使用 glFrontFace(dir) 控制哪些多边形被视为正面/背面,参数为 GL_CW(顺时针)或 GL_CCW >(逆时针)(默认为逆时针,因此如果将其设置为时钟,原始背面多边形将被视为正面)。

You can simply switch the culling mode. You can use glCullFace(mode) to decide which triangles should be culled. Supplying a parameter of GL_BACK means that only front-facing polygons are rendered, while a parameter of GL_FRONT means that only backfacing polygons are rendered. So if your transformation means that the "backfacing" polygons are in fact frontfacing, calling glCullFace(GL_FRONT) should do the trick.

As an alternative you can also control which polygons are considered front/backfacing using glFrontFace(dir), with a parameter of GL_CW (clockwise) or GL_CCW (counterclockwise) (default is counterclockwise so if you set it to clocksie originaly backfacing polygons would be considered frontfacing).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文