3

我目前正在计划一个 Web GL 游戏并开始为它制作模型,我需要知道是否有人知道我的模型是 1X 比例,我的相机从对象缩放/平移,我的模型变成 0.1X 比例,WGL 引擎对视图中的模型进行了什么样的简化?

IE 如果我以三角形为例,这里是 1X 比例 内部有许多三角形的三角形

这是原始大小的 10% 的三角形,同时保持所有复杂性(抱歉它太微弱了)
10% 比例的三角形,里面有很多三角形

虽然三角形看起来相同,但复杂性并非完全必要,并且可以简化为可能为 4 个三角形以提高性能。

我知道 WebGL 是一个状态机,可能什么也没有发生;无论规模或状态如何,模型的复杂性都保持不变,但我如何解决这个问题以获得最佳性能?

由于在 1X 比例下,视图中可能只有一个或很少的模型,但当缩放到 0.1X 比例时,可能会有数百个模型。意思是,如果模型的复杂性太高,那么性能会受到很大的影响,游戏就会变得无响应/无用。

非常感谢所有建议。

4

2 回答 2

3

WebGL doesn't simplify for you. You have to do it yourself.

Generally you compute the distance away from the camera depending on the distance display a different hand made model. Far away you display a low detail model, close up you display a high detail model. There are lots of ways to do this, which way you choose is up to you. For example

  1. Use different high poly models close, low poly far away

    This is the easiest and most common method. The problem with this method is you often see popping when the engine switches from using the low poly model to the high poly model. The three.js sample linked in another answer uses this technique. It creates a LOD object who's job it is to decide which of N models to switch between. It's up to you to supply the models.

  2. Use low-poly far away, fade in the high poly one over it. Once the high poly one is completely obscuring the low poly one stop drawing the low-poly.

    Grand Theft Auto uses this technique

  3. Create low poly from high poly and morph between them using any number of techniques.

    For example.

     1----2----3----4            1--------------4
     |    |    |    |            |              |
     |    |    |    |            |              |       
     4----5----6----7            |              |
     |    |    |    |   <----->  |              |
     |    |    |    |            |              |
     8----9----10---11           |              |
     |    |    |    |            |              |
     |    |    |    |            |              |
     12---13---14---15           12-------------15
    

    Jak and Daxter and Crash Team Racing (old games) use the structure above. Far away only points 1,4,12,15 are used. Close up all 16 points are used. Points 2, 3, 4, 5, 6, 8, 9, 10, 11, 13, 14 can be placed anywhere. Between the far and near distances all the points are morphed so the 16 point mesh becomes the 4 point mesh. If you play Jak and Daxter #1 or Ratchet and Clank #1 you can see this morphing going on as you play. By the second version of those games the artists got good at hiding the morphing.

  4. Draw high poly up close, render high poly into a texture and draw a billboard in the distance. Update the billboard slowly (ever N frames instead of every frame). This is a technique used for animated objects. It was used in Crash Team Racing for the other racers when they are far away.

I'm sure there are many others. There are algorithms for tessellating in real time to auto generate low-poly from high or describing your models in some other form (b-splines, meta-balls, subdivision surfaces) and then generate some number of polygons. Whether they are fast enough and produce good enough results is up to you. Most AAA games, as far as I know, don't use them

于 2013-05-06T16:35:02.410 回答
0

搜索“镶嵌”。有了它,您可以从网格中添加或减去三角形。

细分与 LOD 对象(细节层次)密切相关。

比例因子只是网格的所有顶点相乘的系数,使用比例,您只需沿轴拉伸网格。

看看这个 Three.js 示例: http ://threejs.org/examples/webgl_lod.html (WASD/mouse 移动)

于 2013-05-06T15:28:14.387 回答