直射投影中的OpenGL深度缓冲

时间:2023-01-30 20:05:25

If I use orthographic projection in OpenGL, but still set different z-values to my objects, does it still be visible in Depth Buffer?

如果我在OpenGL中使用正射投影,但仍然为我的对象设置不同的z值,它在深度缓冲中仍然可见吗?

I mean, in color buffer everything looks plain and at one distance. But wherever they will "colorized" in different shades? Does depth buffer "understand" depth in orthographic projection?

我的意思是,在色彩缓冲中,每样东西看起来都是简单的,而且是一段距离。但无论他们将在哪里用不同的色调“上色”?深度缓冲是否在正投影中“理解”深度?

1 个解决方案

#1


2  

A depth buffer has nothing to do with the projection matrix. Simply put, a z-buffer takes note of the closest Z-value at a given point. As things are drawn it looks at the current value. If the new value is less then the existing value it is accepted and the z buffer is updated. If the value is greater then the value, behind the current value, it is discarded. The depth buffer has nothing to do with color. I think you might be confusing blending with depth testing.

深度缓冲与投影矩阵无关。简单地说,z缓冲区在给定的点上记录最近的z值。在绘制时,它会查看当前值。如果新值小于现有值,则接受该值并更新z缓冲区。如果值大于当前值之后的值,则将其丢弃。深度缓冲与颜色无关。我想你可能会把混合和深度测试搞混。

For example, say you have two quads A & B.

例如,假设你有两个A和B。

A.z = - 1.0f;

一个。z = f - 1.0;

B.z = - 2.0f;

B。z = f - 2.0;

If you assume that both quads have the same dimensions, outside of their Z value, then you can see how drawing both would be a waste. Since quad A is in front of quad B it is a waste to draw quad B. What the depth buffer does is checks the zcords. In this example if you had enabled depth testing & a depth buffer quad B would never have been drawn because the depth testing would have shown it was occluded by quad A.

如果你假设两个四边形都有相同的维度,在它们的Z值之外,那么你就可以看到画两个四边形是多么的浪费。因为quad A在quad B的前面,所以画quad B是一种浪费。深度缓冲的作用是检查zcord。在本例中,如果您启用了深度测试&深度缓冲四轴飞行器B将永远不会被绘制出来,因为深度测试将显示它被四轴飞行器a所遮挡。

#1


2  

A depth buffer has nothing to do with the projection matrix. Simply put, a z-buffer takes note of the closest Z-value at a given point. As things are drawn it looks at the current value. If the new value is less then the existing value it is accepted and the z buffer is updated. If the value is greater then the value, behind the current value, it is discarded. The depth buffer has nothing to do with color. I think you might be confusing blending with depth testing.

深度缓冲与投影矩阵无关。简单地说,z缓冲区在给定的点上记录最近的z值。在绘制时,它会查看当前值。如果新值小于现有值,则接受该值并更新z缓冲区。如果值大于当前值之后的值,则将其丢弃。深度缓冲与颜色无关。我想你可能会把混合和深度测试搞混。

For example, say you have two quads A & B.

例如,假设你有两个A和B。

A.z = - 1.0f;

一个。z = f - 1.0;

B.z = - 2.0f;

B。z = f - 2.0;

If you assume that both quads have the same dimensions, outside of their Z value, then you can see how drawing both would be a waste. Since quad A is in front of quad B it is a waste to draw quad B. What the depth buffer does is checks the zcords. In this example if you had enabled depth testing & a depth buffer quad B would never have been drawn because the depth testing would have shown it was occluded by quad A.

如果你假设两个四边形都有相同的维度,在它们的Z值之外,那么你就可以看到画两个四边形是多么的浪费。因为quad A在quad B的前面,所以画quad B是一种浪费。深度缓冲的作用是检查zcord。在本例中,如果您启用了深度测试&深度缓冲四轴飞行器B将永远不会被绘制出来,因为深度测试将显示它被四轴飞行器a所遮挡。