Unity LOD technology

Unity LOD technology

LOD (Level of detail) multi-level details, commonly used Unity optimization technology. It calls and displays models with different precision according to the percentage of the view that the object occupies
in the game screen . Display low-res models when objects are far from the camera


Advantages: optimize GPU performance
Disadvantages: the same model requires multiple models, increasing memory consumption
is to optimize GPU by memory consumption

Use the following
to prepare models of 3 precisions. The following cubes, spheres, and capsules represent high, medium, and low-precision models in turn. (1)
insert image description here
Create a GameObject, and place the cube, sphere, and capsule under the GameObject as sub-objects (not required)

(2) Hang the script LODGroup
and then you can see that it is divided into 4 levels
LOD0, LOD1, LOD2, Culled

(3) Add the cube as a reference to LOD0,
add the sphere as a reference to LOD1,
add the capsule as a reference to LOD2
, Culled does not need to add a reference, and when the Culled level is reached, the model will be removed and
insert image description herethe mouse will no longer be displayed. Press the middle of the two levels Position, you can drag the layer occupancy proportion relationship
preview: drag the camera icon displayed under the LODGroup component left and right, you can preview the model displayed when the camera is at different positions from the model in real time under the editor, and only cubes, spheres, and capsules will be displayed at the same time one of the body
insert image description here

insert image description here

Run Unity, drag the camera or GameObject to control the distance between the camera and the object, and check the model switching

LOD settings
Open Editor->ProjectSettings -> Quality
to find Level of Detail
insert image description here
LOD Bias: LOD deviation, LOD level is based on the size of the object on the screen, when the object size is between the two LOD levels, you can choose to use low detail model or high Detail model, the value range is [0, 1]. The closer the value is to 0, the more inclined to display low-detail models.

Maximum LOD Level: The maximum LOD level, the highest LOD level supported by the game, models above this level will not be used, and will be ignored at compile time (saving storage space and memory space) What is the LOD level
?
Using the above, we can see that there are 4 levels
LOD0, LOD1, LOD2, and Culled,
among which 0, 1, and 2 are the levels, 0 is the highest level (the model with the highest precision), and 2 is the lowest level (the model with the lowest precision is used)

When setting the Maximum LOD to 1, the LOD0 level model will not be used.
I set the Maximum LOD to 2. Although the camera distance is already at the LOD0 position, the displayed model is still LOD2
insert image description here

Guess you like

Origin blog.csdn.net/LIQIANGEASTSUN/article/details/130168552
Recommended