远距离3D物体渲染[游戏]

发布于 2024-07-24 12:03:16 字数 1599 浏览 2 评论 0原文

技术背后的基本前提是什么,例如《湮没》(以及其他游戏,我确信;玩得不够多,不知道)中发现的技术,其中当您从远处观看远处的物体时,它们会模糊地显示出来? 例如,一座大塔在一英里外,你会看到它的模糊矩形从地平线伸出......显然,一个巨大的 3D 场景无法全部渲染,而且我知道在高度图的情况下,只有近似算法用于降低远离相机的高度图质量,但对于特定对象,显示这些的最佳方式是什么?

我在考虑也许是一种预渲染技术,其中您选择景观周围的特定位置,然后编写一个程序来绘制该位置周围的所有高度图和 3D 模型并拍照。 它会拍摄几张照片,然后当玩家靠近该地点时,这些照片将用作天空盒。

另一种更明显的技术是存储真正粗糙的 3D 模型,但是 3D 渲染系统如何专门选择渲染建筑物的粗糙模型,而不是其他不太重要的(并且可能无法从该模型中查看)的粗糙模型距离)物体? 您如何将类似的东西与高度图一起存储? 也许按照设计,只有几个这样重要的地标,然后将它们的列表存储在一个小文件中,并在每个帧上渲染小于 x 真正远距离的地标?

我知道光环系列选择将游戏分为多个级别,然后每个级别都有不同的手工制作的天空盒。 这就是我在第一个建议中想要的,但我不确定。 我想我真的只是想收集我的想法中的其他想法或改进或问题,以便我可以用我有限的时间和知识来选择哪些想法进行原型设计。

另一个相关主题是如何在远处显示山脉,因为它们将是高度图的一部分,而不是其之上的 3D 模型,因此它们实际上无法拥有粗略版本,并且高度图近似算法可能会出错从像这样的非常远的距离上山(假设您甚至会尝试近似并渲染如此遥远的几何图形,但您可能不会)。 如果您在答案中也涵盖了这一点,则会获得加分。 :)

谢谢!

PS我正在使用OpenGL。 我只是在寻找基本概念,但如果您选择发布示例代码,请使用 OpenGL 函数和术语! :)

编辑:感谢您的回答! 出于文档目的,这里是我找到的另一个资源: 《游戏编程宝典 2》中的第 4.9 章介绍了将远处的风景渲染到天空盒的概念: http://books.google.com/books?id=1-NfBElV97IC&lpg=PA416&ots=SOpnfijZly&dq=render%20distant%20to%20skybox&pg=PA416 (不幸的是,预览只是本章的第一页......八月份一回来,我就必须从大学图书馆拿那本书)

另外,在读完这些东西之后,我仍然认为 LOD适用于距离仍然相当近的物体。 如果对象甚至不到一像素大,但您仍然将它们输入到显卡,那么无论是否使用 LOD,您都只是在浪费电量。 除了绝对最大的遥远物体之外,所有物体都是如此。 在大多数情况下,一些高楼和一些山脉,但小细节模型(灌木丛,甚至树木,岩石,无论其他风景......)从这么远的距离是看不到的。 所以我确实喜欢渲染天空盒技术,当我到达这座桥时,我就会通过它; 我将确保对所有模型使用 LOD,只是不会渲染这样的距离。

顺便说一句,我更多地按照《遗落战境》游戏的思路思考,所以答案可能取决于游戏类型。

What is the basic premise behind technology such as is found in Oblivion (and other games, I'm sure; haven't played enough to know), wherein objects from afar are vaguely shown when you view them from a distance? For example, a large tower is a mile away and you see the vague rectangle of it sticking up from the horizon... Obviously a giant 3D scene cannot all be rendered, and I know that in the case of heightmaps there are just approximation algorithms that are used to reduce the heightmap quality further away from the camera, but for specific objects, what is the best way to show those?

I was thinking perhaps a pre-rendering technique, wherein you pick specific places around the landscape and then make a program that draws all of the heightmap and 3D models around that spot and takes a picture. It would take several pictures, and then when the player is near that spot, the pictures would be used as a skybox.

Another more obvious technique is to store really rough 3D models, but then how does the 3D rendering system specifically choose to render the rough model of the building and not the rough models of other less significant (and probably not-viewable-from-that-distance) objects? How would you store something like that along with your heightmap? Maybe by design, only have a few such significant landmarks and then just store the list of them in a small file, and on each frame render the ones that are less than x really-far-distance away?

I am aware that the Halo series chooses to divide the game into levels and then each level has a different hand-made skybox. This is kind of what I was going for in the first suggestion, but I'm not sure about it. I guess I'm really just trying to collect other ideas or refinements or issues in my ideas, so that I can choose which ones to prototype with my limited time and knowledge.

Another related topic is how to display mountains at a distance, since they would be part of the heightmap and not 3D models on top of it, so they wouldn't really be able to have a rough version, and the heightmap approximation algorithm might screw up the mountain from a really far distance like that (assuming you would even try to approximate and render such distant geometry, which you probably would not). Bonus points if you cover this in your answer too. :)

Thanks!

P.S. I'm using OpenGL. I am just looking for the basic concepts but if you choose to post example code, please use OpenGL functions and terms! :)

EDIT: Thanks for the answers! For documentation purposes here is another resource I found:
Chapter 4.9 in Game Programming Gems 2 covers the concept of rendering distant scenery to a skybox:
http://books.google.com/books?id=1-NfBElV97IC&lpg=PA416&ots=SOpnfijZly&dq=render%20distant%20to%20skybox&pg=PA416
(unfortunately that preview is only the first page of the chapter... I'll have to grab that book from my university's library as soon as I get back in August)

Also after reading these things, I am still of the opinion that LOD is for objects that are at a still reasonably close distance. If the objects aren't even one pixel large, but you're still feeding them to the graphics card, you're just wasting power, whether using LOD or not. And that would be the case for everything but the absolute largest distant objects; a few tall buildings and some mountains, in most cases, but the small detail models (bushes, even trees, rocks, whatever other scenery...) would not be visible from such a distance. So I do like the render to skybox technique, and when I get to this bridge, that's how I'll cross it; and I'll make sure to use LOD for all models, I just won't render such a distance.

I am, by the way, thinking more along the lines of an Oblivion game, so the answer may depend on the game genre.

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

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

发布评论

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

评论(8

江南烟雨〆相思醉 2024-07-31 12:03:16

一些技巧,包括您提到的那些:

  • 详细程度。 上面概述了。
  • 纹理贴图。 对于纹理。
  • 视野。 通过选择适当的缩放级别来限制相机可以“看到”的事物数量。 另请参见视锥体剔除。
  • 远剪裁平面。 遥远地方的遮挡:大多数游戏都会使用雾、山脉或其他一些借口来严格限制您能看到的距离。 这可以使用八叉树或其他一些此类技术来实现。 这可能基于整个对象、多边形或其他任何东西,并且通常设置为发生在上述山脉的后面。
  • 竞技场/关卡/区域/无论什么——大多数游戏都会人为地限制你一次只能在一个竞技场中玩; 好处是显而易见的(你可以忽略所有其他领域中的对象)
  • 预渲染——这就是你上面建议的。 对于远处的静态场景,在“典型”视图中渲染场景并使其成为背景上的纹理,或将其用于天空盒/反射贴图/等。

其想法是丢弃尽可能多的细节在用户开始注意到之前。

有许多预先存在的工具包可以自动完成这些事情,但它们往往需要花钱。 如果您正在寻找一个严肃的应用程序,我建议您至少研究一下它们包含的解决方案。

A few techniques, including the ones you've mentioned:

  • Level of detail. Outlined above.
  • Mipmapping. For textures.
  • Field of view. Restrict how many things your camera can 'see' by picking an appropriate zoom level. See also view frustrum culling.
  • Far-clipping plane. Occlusion of far-off places: most games use fog, mountains, or some other excuse to have a hard cut-off on how far away you can see. This can be implemented using octrees, or some other such technique. This may be based on whole objects, or polygons, or whatever, and is usually set to occur right behind those aforementioned mountains.
  • Arenas/levels/areas/whatever -- again most games artificially restrict you to playing in one arena at a time; the benefit is obvious (you get to ignore objects in all other arenas)
  • Pre-rendering -- this is what you're suggesting above. For static scenes that are far off, render the scene in a 'typical' view and make it a texture on the background, or use it for the skybox / reflection map / etc.

The idea is to throw away as much detail as is possible before users start to notice.

There are a number of pre-existing toolkits that will do these things automatically, but they tend to cost money. If you're looking at a serious app, I would recommend at least researching the solutions they include.

感受沵的脚步 2024-07-31 12:03:16

我认为这就是您正在寻找的细节级别(LOD)

I think this is what your looking for Level of Detail (LOD)

想你只要分分秒秒 2024-07-31 12:03:16

对于 3D 模型,该技术称为细节级别。 本质上,多个版本的模型保持可用,并根据上下文使用正确的模型。 它并不总是仅仅用于距离,它还可以用于在其他情况下保持帧速率。

但要小心,您应该启用 mipmap,否则您会在较低分辨率模型上的较大纹理上闪闪发光,并且要小心动画。 在动画骨架下切换模型很棘手,因此一种技术是即使在对模型进行 LOD 处理时也保持相同的骨架。

地形和对象模型都有动态 LOD 系统,但这些系统可能会占用大量 CPU 资源。

For 3d models, the technique is called level of detail. Essentially, multiple versions models are kept available the the right one use based on context. It is not always just for distance, it can also be used to maintiain framerate in other situations.

Be careful though, you should have mipmapping enabled or you'll get sparkling on the larger textures on the lower res models, and be careful of animation. Switching the model beneath an animating skeleton is tricky so one technique is to maintain the same skeleton even when LOD-ing the model.

There are dynamic LOD systems for both terrain and for object models, but these can be CPU heavy.

雨夜星沙 2024-07-31 12:03:16

您可以渲染远处物体的纹理,但是每次透视变化超过某个阈值时,您都必须重新渲染纹理。 它对于远处的物体非常有用,因为远距离的物体的视角不会经常改变,就像远处的山脉的例子一样,但是如果视图源移动太快或者你太近,那么你会得到类似于鱼眼的效果地震中天空渲染的早期阶段。 这种系统将其自身应用到像《Eve Online》这样距离遥远的世界中。

这当然只是你武器库中的另一个技巧,在某种程度上你仍然需要 LOD。

You can render to textures for distant objects however you have to re-render the texture every time the perspective changes beyond some threshold. It works great for distant objects where the perspective won't change that often like your example of the mountains in the distance however if the the view source is moving too fast or you are too close then you will get a fish eye effect kind of like the early days of sky rendering in quake. This kind of system lends it's self to worlds like eve online which contain vast distances.

This of course is but another trick in your arsenal and you will still need LOD to some extent.

眼藏柔 2024-07-31 12:03:16

模型的低细节版本尤其适用于车辆和物体。地形确实很棘手。 我曾开发过战区类游戏和 PC 飞行模拟器。 一点雾有助于掩盖细节之间的“流行”。

在较低的细节处,纹理映射通常被一些单色多边形取代。


“另一个更明显的技术是存储真正粗糙的 3D 模型,但是 3D 渲染系统如何专门选择渲染建筑物的粗糙模型,而不是其他不太重要的(并且可能无法从中看到的)粗糙模型-距离)物体?你如何将这样的东西与你的高度图一起存储?”

您可以对地形进行网格化,并保留每个网格单元中可见对象的列表。

Low-detail versions of models work especially well for vehicles and objects It's really tricky with terrain. I've worked on battlezone-type games and PC flight simulators. A little fog helps cover up the "pops" between details.

At the lower details, texture-mapping is often replaced with a few single-color polygons.


"Another more obvious technique is to store really rough 3D models, but then how does the 3D rendering system specifically choose to render the rough model of the building and not the rough models of other less significant (and probably not-viewable-from-that-distance) objects? How would you store something like that along with your heightmap?"

You can grid your terrain and keep a list of which objects are visible in each grid cell.

梦初启 2024-07-31 12:03:16

处理地形的一种方法是使用多分辨率图块。 就像虚拟地球和谷歌地图的做法一样,它们以递归方式将世界划分为多个图块。 因此,0 级有 4 个图块,1 级有 16 个图块,等等...然后,使用某种 LoD 算法来确定缩放/比例,您将为给定区域加载适当的地形图块。

One way to handle terrain is to have multi-resolution tiles. Much like how Virtual Earth and Google Maps do it, they divide the world into tiles in a recursive fashion. So, there are 4 tiles at level 0, 16 at level 1, etc... Then, using some LoD algorithm to determine the zoom/scale, you would load the appropriate terrain tiles for the given area.

︶葆Ⅱㄣ 2024-07-31 12:03:16

动态缓存远处物体的预渲染视图的技术通常称为“冒名顶替者”。 这是一篇关于该主题的旧游戏编程宝石书中的文章。

有许多技术可以处理高度图地形的细节级别。 请访问 vterrain.org,了解一些常见技术的概述。 大多数变体的一般原理是相同的 - 将地形分成几个部分并在远处使用较低分辨率的几何图形和纹理 - 但细节有所不同。

为了减少提交给显卡的对象数量,通常会实施某种可见性剔除。 最简单的情况是,这可能只是完全丢弃边界球覆盖的屏幕像素小于特定阈值的模型(如果您有 LOD 系统,那么在选择要使用的 LOD 时无论如何都会计算此值)。 为了提高效率,可以使用某种用于剔除的分层空间数据结构 - 四叉树或八叉树、球体树、门户系统(通常不太用于室外环境)、简单的基于网格的方案等。基本思想是节省工作通过剔除层次结构中的较高级别节点,从而避免查看许多叶节点。 一个简单的例子是剔除建筑物并有效地剔除其所有子节点(建筑物内部或顶部的对象),而无需单独查看它们。

对于像《遗忘》这样的游戏,他们可能还会进行某种遮挡剔除——根据确定对象隐藏在其他对象后面,在将对象提交给图形硬件之前对它们进行剔除。 有多种技术可以实现此目的,其中一些技术可能非常复杂。

The technique of dynamically caching pre-rendered views of distant objects is usually called 'impostors'. Here's an article from an old Game Programming Gems book on the subject.

There are many techniques for handling level of detail for heightmap terrain. Take a look at vterrain.org for an overview of some common techniques. The general principle is the same in most variants - break the terrain into sections and use lower resolution geometry and textures in the distance - but the details vary.

To reduce the number of objects that get submitted to the graphics card some kind of visibility culling will usually be implemented. At it's simplest this may be just completely dropping models whose bounding sphere covers less than a certain threshold of screen pixels (you'll be calculating this anyway when choosing which LOD to use if you have an LOD system). For greater efficiency some kind of hierarchical spatial data structure for culling may be used - quadtrees or octtrees, sphere trees, portal systems (not generally much used for outdoor environments), simple grid-based schemes, etc. The basic idea is to save work by culling a higher level node in the hierarchy and thus avoiding even looking at many leaf nodes. A simple example would be culling a building and effectively culling all of its child nodes (objects inside or on top of the building) without looking at them individually.

For a game like oblivion they are probably also doing some kind of occlusion culling - culling objects before submitting them to the graphics hardware based on determining that they are hidden behind other objects. There are a variety of techniques for doing this, some of them can be quite complex.

嘿看小鸭子会跑 2024-07-31 12:03:16

一种技术是 LOD(细节级别)。 物体离相机越远,绘制的三角形就越少。 这是一个链接: http://www.stefan -krause.com/

One technique is LOD (level of detail). The farther an object is from the camera, the less triangles are drawn. Here's a link: http://www.stefan-krause.com/

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