0

A colleague and I are talking about how scenes are typically rendered in complex games. He believes the world is rendered recursively in the truest object-oriented fashion, with the world's many actors each overriding a virtual function like Actor.Draw() (e.g. Koopa.Draw(), Goomba.Draw()).

By contrast, I imagined that complex games today would iterate over their scene graph, avoiding virtual function overhead and allowing more flexibility for specialized iterators (e.g. near-to-far vs. far-to-near, skipping certain objects in the tree, etc.) And my experience with OpenGL and DirectX suggested to me that they tend to draw objects in batch, and passing a batch context through a recursive call (i.e. the batch into which a class's Draw() function would draw) seemed like additional parameter-passing overhead that could be avoided with iteration.

Is one method favored over another nowadays? If so, why?

4

1 に答える 1

2

シーン グラフの一部の更新は、再帰的に行われる場合があります。ただし、描画は通常、空間分割データ構造とジオメトリ/レンダリング状態バッチャーを介して行われ、(前後に描画することで) オーバードローを防ぎ、レンダリング パイプラインの状態の切り替えを最小限に抑えます (データのバッチ処理、同様のものを使用する描画呼び出し)。リソースとレンダリング状態)。通常、この描画部分はある意味反復的です。

シーンの複雑さ、構成、描画されるオブジェクトの数を考慮する必要があります。単純なシーンのプロジェクトや事前に特定の情報を持っているプロジェクトの場合、レンダリングを (ほぼ) 最適に順序付けしても、描画順序やバッチ処理を計算する実際のコストに見合う価値はありません。

最終的に、「優先」メソッドはプロジェクト固有になります。

于 2012-04-04T23:57:07.193 に答える