Related Posts Plugin for WordPress, Blogger...

5-2 Level of Detail (LOD)

本次優化要來介紹LOD技術,以下引用Unity官方的一段介紹:

When a GameObject in the scene is a long way from the camera, the amount of detail that can be seen on it is greatly reduced. However, the same number of triangles will be used to render the object, even though the detail will not be noticed. An optimisation technique called Level Of Detail (LOD) rendering allows you to reduce the number of triangles rendered for an object as its distance from the camera increases. As long as your objects aren’t all close to the camera at the same time, LOD will reduce the load on the hardware and improve rendering performance.

https://docs.unity3d.com/Manual/LevelOfDetail.html

簡而言之,對於一個非常精緻的遊戲物體而言,當玩家離遊戲中該物體越遠,越不容易去注意該物體的細節。但是對系統來說,仍然需要耗費資源去產生如此精緻的遊戲物體,所以LOD技術的好處便是當玩家距離物體較遠時,將物體切換成精緻度較低的3D模型(如面片數較低)。

首先,大家可以在場景中的Gizmos選項打開Selection Wire,方便觀察3D模型的精緻程度。

以下有3種錘子,很顯然這3種錘子的外形相似,但是模型的面數不同。



我們當然會希望使用者在最靠近這個錘子的時候,可以看見最精緻的模型。首先我們建立一個Empty GameObject,並新增一個Component,名為LOD Group。

大家可以看見LOD Group共有四個層級,最後一個層級名為Culled,當玩家距離3D模型太遙遠時,將會直接關閉顯示該模型。

請大家將模型拖曳到每個對應的層級後,移動上面的攝影機來試看看效果。

如下圖,LOD 0為最精緻的程度。

接著推拉攝影機,發現錘子模型被切換到LOD 1,但由於距離相當遙遠,我們的肉眼無法準確地看出這個錘子變得沒那麼精緻了。

於LOD Group中也可以針對層級設定距離唷,就請大家依據自己的喜好進行調整吧。

留言