为什么 OpenGL 有一个远剪裁平面,用什么习语来处理这个问题? [英] Why does OpenGL have a far clipping plane, and what idioms are used to deal with this?

查看:19
本文介绍了为什么 OpenGL 有一个远剪裁平面,用什么习语来处理这个问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在学习 OpenGL,一直困扰着我的一个话题是远剪裁平面.虽然我可以理解近剪裁平面和侧剪裁平面背后的推理(它们从来没有任何实际效果,因为无论如何都不会渲染它们之外的对象),但远剪裁平面似乎只是一个烦恼.

I've been learning OpenGL, and the one topic that continues to baffle me is the far clipping plane. While I can understand the reasoning behind the near clipping plane, and the side clipping planes (which never have any real effect because objects outside them would never be rendered anyway), the far clipping plane seems only to be an annoyance.

由于 OpenGL 背后的人显然已经考虑到了这一点,我知道一定有我遗漏的东西.为什么 OpenGL 有一个远剪切平面?更重要的是,因为您无法关闭它,所以在远距离绘制物体时(对于太空游戏中数千个单位以外的物体,天空盒等),推荐使用的习语和做法是什么?你是希望剪裁平面离得很远,还是有更优雅的解决方案?这是如何在生产软件中完成的?

Since those behind OpenGL have obviously thought this through, I know there must be something I am missing. Why does OpenGL have a far clipping plane? More importantly, because you cannot turn it off, what are the recommended idioms and practices to use when drawing things at huge distances (for objects such as stars thousands of units away in a space game, a skybox, etc.)? Are you expected just to make the clipping plane very far away, or is there a more elegant solution? How is this done in production software?

推荐答案

唯一的原因是深度精度.由于深度缓冲区中只有有限数量的位,因此您也可以用它表示有限数量的深度.

The only reason is depth-precision. Since you only have a limited number of bits in the depth buffer, you can also just represent a finite amount of depth with it.

但是,您可以将远平面设置为无限远:请参阅this.它只是不能很好地与深度缓冲区配合使用 - 如果您在远处有遮挡,您会看到很多伪影.

However, you can set the far plane to infinitely far away: See this. It just won't work very well with the depth buffer - you will see a lot of artifacts if you have occlusion far away.

因此,由于这是围绕深度缓冲区进行的,因此只要您不使用它,处理更远的东西就不会遇到问题.例如,一种常见的技术是在slabs"中渲染场景,每个只在内部使用深度缓冲区(对于一个slab中的所有东西),但在外部使用某种形式的画家算法(对于slabs,所以你绘制最远的一个第一)

So since this revolves around the depth buffer, you won't have a problem dealing with further-away stuff, as long as you don't use it. For example, a common technique is to render the scene in "slabs" that each only use the depth buffer internally (for all the stuff in one slab) but some form of painter's algorithm externally (for the slabs, so you draw the furthest one first)

这篇关于为什么 OpenGL 有一个远剪裁平面,用什么习语来处理这个问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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