Opengl 深度缓冲区和剔除

发布于 2024-08-21 23:43:41 字数 33 浏览 4 评论 0原文

OpenGL 中使用背面剔除和深度缓冲区有什么区别?

Whats's the difference between use back face culling and a buffer of depth in OpenGL?

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

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

发布评论

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

评论(2

帅哥哥的热头脑 2024-08-28 23:43:41

背面剔除是指 OpenGL 确定哪些面背对观看者,因此不可见。想象一个立方体。无论你如何旋转立方体,三个面始终是不可见的。找出这些面是哪些面,将它们从要绘制的多边形列表中删除,这样您就将绘制列表减半了。

深度缓冲相当简单。对于绘制的每个多边形的每个像素,将其 z 值与 z 缓冲区进行比较。如果它小于 z 缓冲区中的值,则将 z 缓冲区值设置为新的 z 缓冲区值。如果不是,则丢弃该像素。深度缓冲提供了非常好的结果,但可能相当慢,因为每个像素都需要查找值。

实际上,这两种方法没有任何相似之处,并且经常同时使用。给定一个立方体,您可以首先使用剔除切出一半的多边形,然后使用 z 缓冲绘制它们。

剔除可以减少渲染的多边形,但它不是排序算法。这就是 Z 缓冲。

Backface culling is when OpenGL determines which faces are facing away from the viewer and are therefore unseen. Think of a cube. No matter how your rotate the cube, 3 faces will always be invisible. Figure out which faces these are, remove them from the list of polygons to be drawn and you just halved your drawing list.

Depth buffering is fairly simple. For every pixel of every polygon drawn, compare it's z value to the z buffer. if it's less than the value in the z buffer set the z buffer value as the new z buffer value. If not, discard the pixel. Depth buffering gives very good results but can be fairly slow as each and every pixel requires a value lookup.

In reality there is nothing similar between these two methods and they are often both used. Given a cube you can first cut out half the polygons using culling then draw them using z buffering.

Culling can cut down on the polygons rendered, but it's not a sorting algorithm. That's what Z buffering is.

请你别敷衍 2024-08-28 23:43:41

给定的三角形有两条边,即正面和背面。您所看到的一侧由点在顶点列表中出现的顺序(也称为缠绕)决定。通常,三角形列表具有交替缠绕,以便您可以重复使用前面的两个点,但条带中给定三角形的面不会交替。背面剔除是优化步骤,其中场景中远离视图的三角形将从要绘制的三角形列表中删除。

深度缓冲区(z 缓冲区)用于挂起已渲染的最近的事物(深度相对于视图)。如果绘制列表中接下来出现的东西位于我已经绘制的东西后面(即,它的深度使其距离更远),我可以跳过绘制它,因为它被阻挡了。如果要绘制的新事物更接近,我会绘制它并使用新的更接近的值更新深度缓冲区。

A given triangle has two sides, the front face and the back face. The side you are looking at is determined by the order the points appear in the vertex list (also called the winding). Typically lists of triangles have alternating winding so that you can reuse the preceding two points but the facing of a given triangle in the strip doesn't alternate. Back face culling is the optimization step where in triangles in the scene which are oriented away from the view are removed from the list of triangles to draw.

A depth buffer (z-buffer) is used to hang onto the closest thing (the depth is relative to the view) that has already been rendered. If the thing that comes up next in the draw list is behind something that I've drawn already (ie, it has a depth that places it farther away) I can skip drawing it, as it is obstructed. If the new thing to draw is closer, I draw it and I update the depth buffer with the new, closer value.

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