OpenGL - 选择性世界渲染

发布于 2024-12-13 03:10:04 字数 183 浏览 0 评论 0原文

我正在建造一个微型城市,具有城市的基本最低外观(道路、建筑物、树木等),您可以在其中四处走动。我知道在每个帧中渲染整个模型集是行不通的...

那么任何人都可以让我了解用于选择性地仅渲染系统的可见部分的标准(但最简单)程序吗?我的意思是,只显示可见的东西(相对于相机位置)而不渲染不可见的部分。 我使用 VC++ 和 GLUT API。

I'm building a miniature city with the basic minimum looks of a city (roads,buildings,trees etc) where u can move around. I know that rendering the whole model set in each frame doesn't work...

So can anyone give me an insight on the standard (but easiest) procedure used in selectively rendering only the visible parts of the system? I mean, just displaying only the visible stuff (with respect to the camera position) and not rendering the unseen part..
Im using VC++ and GLUT API.

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

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

发布评论

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

评论(2

墟烟 2024-12-20 03:10:04

也许这篇维基百科文章提供了剔除技术领域的非常基本的介绍。

视锥体剔除是一个很好的起点,也是最简单的技术之一。使用此方法,您可以检查场景中的每个对象是否位于查看体积(查看视锥体)内。这基本上相当于检查几何体的一些简化边界体积(例如完全包含几何体的盒子或球体),如果它位于由六个平面定义的视锥体内。

这可以通过按位置对对象进行分组并创建所谓的包围体层次结构来进一步优化,例如,您可以首先检查整个城市街区是否位于查看体内部(通过使用包含整个街区的包围体),然后如果是的话,你再进一步检查个别房子。

一种更复杂的技术是遮挡剔除,这意味着检查一个对象是否完全隐藏在另一个对象后面。因为这些技术可能变得更加复杂,所以实际上应该(如果完成)在视锥体剔除之后完成。 OpenGL 具有硬件遮挡查询,可以帮助您确定对象是否实际上可见,但它们需要一些额外的工作才能正常工作。特别是对于城市来说,可能会有特殊的二维遮挡剔除技术(很早以前就听说过,不知道)。

这只是一个非常广泛的概述,请随意使用谷歌搜索各个关键字。如果额外的 CPU 开销值得的话(特别是使用复杂的遮挡剔除技术),仔细权衡总是一个好主意,考虑到现在的趋势是将尽可能多的几何体批处理到单个绘制调用中(顺便说一句,我希望您不要使用立即模式 glBegin/glEnd,否则将其更改为顶点数组或更好的 VBO 是您议程上的第一点)。但视锥体剔除可能是一个很好且简单的起点,特别是当城市变得相当大时。

Maybe this Wikipedia article provides a very basic introduction to the field of culling techniques.

A good starting point and one of the easiest techniques is view frustum culling. With this method you check for each object in your scene if it is inside the viewing volume (viewing frustum). This basically amounts to checking for some simplified bounding volume of the geometry (like a box or a sphere, that completely contain the geometry) if it lies inside the viewing frustum, defined by six planes.

This can further be optimized by grouping objects by their position and create a so-called bounding volume hierarchy, this way you e.g. first check if a whole city block is inside the viewing volume (by using a bounding volume that contains the whole block) and only if it is, you further check the individual houses.

A more complicated technique is occlusion culling, which means checking if an object is completely hidden behind another object. Because these techniques can get substantially more complicated it should (if done) actually be done after the view frustum culling. OpenGL has hardware occlusion queries that can aid you in determining if an object is actually visible, but they require some additional work to work well. Especially for cities there may be special two-dimensional occlusion culling techniques (long time ago I heard about that, don't know).

This is just a very broad overview, feel free to google for individual keywords. It is always a good idea to carefully weight if the additional CPU-overhead is worth it (especially with complicated occlusion culling techniques), considering that nowadays the trend is to batch as many geometry as possible into a single draw call (by the way, I hope you don't use immediate mode glBegin/glEnd, otherwise changing this to vertex arrays or better VBOs is the first point on your agenda). But view frustum culling might be a nice and easy starting point, especially if the city gets rather large.

很糊涂小朋友 2024-12-20 03:10:04

谷歌“二元空间划分树”。

BSP 树是确定应该从相机的视角和位置渲染什么的好方法。老式第一人称射击游戏,即《雷神之锤》等人,就使用了它们(或者至少是该原理的一些推导)。

这是一个很好的 常见问题解答

其他好资源:
链接
链接

Google "binary space partition trees".

BSP trees are a good means of determining what should be rendered from the camera's view angle and position. The old-school first-person shooters, i.e. Quake et al, used them (or at least some derivation of the principle).

Here is a good FAQ.

Other good resources:
link
link

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