Level Of Detail – Arma Reforger

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Fix dev → diag menu)
m (Some wiki formatting)
 
(3 intermediate revisions by the same user not shown)
Line 2: Line 2:
== Basics ==
== Basics ==


'''L'''evel '''O'''f '''D'''etail ('''LOD''') in words one LOD or more LODs ('''LOD0, LOD1 - LODn''') are versions of a '''model with specific triangle and shader complexity'''. The lower the LOD number is the better the quality/higher complexity is. LOD0 stands for the nicest and most performance heavy one. Then the higher the number, the less complex and often also worse looking the model is.
'''L'''evel '''O'''f '''D'''etail ('''LOD''') in words one LOD or more LODs ('''LOD0, LOD1 - LODn''') are versions of a '''model with specific triangle and shader complexity'''.
The lower the LOD number is the better the quality/higher complexity is. LOD0 stands for the nicest and most performance heavy one. Then the higher the number, the less complex and often also worse looking the model is.


These performance cheaper model variants (all but LOD0) are to be rendered generally at higher distances in order to save performance on GPU (graphic card). The closer the LODs are rendered, the more GPU performance it saves. User, who will set lower quality in '''Settings/Video/Model geometric detail''' in running game will get closer switching to worse LODs to save more performance.
These performance-cheaper model variants (all but LOD0) are to be rendered generally at higher distances in order to save performance on the GPU.
The closer the LODs are rendered, the more GPU performance it saves. A user who will set lower quality in '''Settings/Video/Model geometric detail''' in the game's options will get closer switching to worse LODs to save more performance.


How to set which model part will be part of which LOD is described elsewhere (FBX import), but generally put the {{hl|_LODn}} suffix into object name inside FBX.
How to set which model part will be part of which LOD is described elsewhere (FBX import), but generally put the {{hl|_LODn}} suffix into object name inside FBX.
Line 11: Line 13:
== Preview ==
== Preview ==


How each LOD is looking, what materials they have and how much triangles or vertices they have can be directly checked in Workbench. Just find desired XOB model in the Resource Browser and double-click on it. Then check Details tab on right part of the viewport and open sub-tab LODs. Then, if "Force selected LOD to render" is checked, it is possible to scroll through the LODs and actually see them.
How each LOD is looking, what materials they have and how much triangles or vertices they have can be directly checked in Workbench. Just find the desired XOB model in the Resource Browser and double-click on it.
Then check the Details tab on the right part of the viewport and open its LODs sub-tab. Then, if "Force selected LOD to render" is checked, it is possible to scroll through the LODs and actually see them.


[[File:armareforger_levelofdetail-preview.png|400px]]
[[File:armareforger_levelofdetail-preview.png|400px]]
Line 18: Line 21:
== Debug ==
== Debug ==


There is a diagnostic tool, which tells which LOD is currently visible on any visible entity instance in a map in World editor. Turn it on with the [[Arma Reforger:Diag Menu|Diag Menu]] by pressing: {{Controls|Alt|Win}} → '''Scene/Colorize objects LODs'''. Now each LOD except for LOD0 will have color overlay. If no other than LOD0 is present for the object, then it will constantly switch all colors.
There is a diagnostic tool which tells which LOD is currently visible on any visible entity instance in a map in {{Link|Arma Reforger:World editor|World editor}}.
Turn it on with the {{Link|Arma Reforger:Diag Menu|Diag Menu}} by pressing {{Controls|Alt|Win}} → '''Scene/Colorize objects LODs'''.
Now each LOD except for LOD0 will have color overlay. If no other than LOD0 is present for the object, then it will constantly switch all colors.
{| class="wikitable"
{| class="wikitable"
| no color overlay
| no color overlay
Line 42: Line 47:
== Automatic System ==
== Automatic System ==


Why automatic system, when other engines offer manual control of LOD behaviour? Automatic system is much less prone to human error and always ensure LOD functionality, even though it might not be always ideal. For these "not ideal" cases there are manual overrides which will be presented later.
Why an automatic system, when other engines offer manual control of LOD behaviour?
The automatic system is much less prone to human error and always ensures LOD functionality, even though it might not be always ideal.
For these "not ideal" cases there are manual overrides which will be presented later.
 
The LOD system tries to keep a constant triangle/pixel ratio across the screen.
It is possible to estimate LOD distances considering LOD factors as a multiplier of triangle count that will change the system's behaviour into earlier/further LODing distance.


=== LOD0 - LOD1 ===
=== LOD0 - LOD1 ===
Line 48: Line 58:
When the model switches from LOD0 to LOD1 (generally begins to switch LODs) depends on several parameters:
When the model switches from LOD0 to LOD1 (generally begins to switch LODs) depends on several parameters:


* Spherical size of the object - the larger the object is, the further away it starts to switch to worse LODs<br>[[File:armareforger_levelofdetail-boundingsphere.jpg|200px]]
* Spherical size of the object - the larger the object is, the further away it starts to switch to worse LODs[[File:armareforger_levelofdetail-boundingsphere.jpg|200px|right]]{{Clear}}
* Triangle count of LOD0 - the more triangles the closer it starts to switch to LOD1<br>[[File:armareforger_levelofdetail-trianglecount.png|200px]]
* Triangle count of LOD0 - the more triangles the closer it starts to switch to LOD1[[File:armareforger_levelofdetail-trianglecount.png|200px|right]]{{Clear}}
* Field of View (FOV) - the larger FOV the closer it starts to switch to worse LODs<br>[[File:armareforger_levelofdetail-fov.png|500px]]
* Field of View (FOV) - the larger FOV the closer it starts to switch to worse LODs[[File:armareforger_levelofdetail-fov.png|500px|right]]{{Clear}}
* Graphic settings - "Model geometric detail" on Ultra results in switching to worse LODs further away, Lowest vice-versa<br>[[File:armareforger_levelofdetail-model-geometric-detail.png|500px]]
* Graphic settings - "Model geometric detail" on Ultra results in switching to worse LODs further away, Lowest vice-versa[[File:armareforger_levelofdetail-model-geometric-detail.png|500px|right]]{{Clear}}
 
There is a formula, which takes all these aspects into account and result is model with LODs switching in a certain way. Understanding this formula will help to deliver better optimised and better looking model.
 
{{Wiki|WIP}}


[[File:armareforger_levelofdetail-lod-1-2-3.png|300px|thumb|LOD1-2-3 size and triangle count]]
=== LOD1 - LOD2 - LOD3+ ===
=== LOD1 - LOD2 - LOD3+ ===


When model starts to switch from LOD1 to LOD2, LOD2 to LOD3 and so on depends on 2 things:
When the model starts to switch from LOD1 to LOD2, LOD2 to LOD3 and so on depends on two criteria:
 
* when spherical surface size of current loaded LOD on monitor screen reached '''half size againts the original screen surface size''' when the current LOD appeared on the screen, then +- at that moment it switches to next LOD and so on. +- because it also depends also on the second thing
* the second thing is relative '''triangle count between LODs'''. When each LOD have exactly '''half triangle count of the previous one''', then the first rule based on surface size apply exactly. When the relative triangle count is not done more or less by half, then it might switch a lot sooner than later.<br>[[File:armareforger_levelofdetail-lod-1-2-3.png|300px]]<br>Sometimes the LODs are not switching exactly ideally and to fix or adjust it there are manual overrides.


* The LOD switch happens roughly when the spherical surface size of the currently loaded LOD on the screen reaches '''half the size compared to the moment of its first appearance''', and the same goes for the next LOD.<!--
--> "Roughly" because it also depends on the other criterion:
* Relative '''triangle count between LODs''' - when each LODs have exactly '''half the triangle count of the previous one''', then the first rule based on surface size applies exactly.<!--
--> When the relative triangle count is not done more or less by half, then it might switch a lot sooner or later.<br><br><!--
-->Sometimes the LODs are not switching ideally. To save the most performance and get the most from LODs, there are manual overrides.


{{Clear}}
== Manual Override ==
== Manual Override ==


The "triangle count" parameter, which heavily influence how fast or slowly prefab is LODing, can be overridden with '''"LOD Factors"'''.
The "triangle count" parameter, which heavily influence how fast or slowly prefab is LODing, can be overridden with '''"LOD Factors"'''.


Yet it multiplies it only for the LOD switching behavior and it is not really increasing/decreasing number of triangles in the model so keep calm. By setting it, it just forces the specific LOD to remain in the scene for shorter (more triangles) or longer (less triangles) distance from the camera until it switches to the next LOD.
Yet it multiplies it only for the LOD switching behaviour and it is not really increasing/decreasing number of triangles in the model.
By setting it, it just forces the specific LOD to remain in the scene for shorter (more triangles) or longer (less triangles) distance from the camera until it switches to the next LOD.


The parameter can be found in '''Entity/Mesh object component/LOD Factors'''.<br>[[File:armareforger_levelofdetail-meshobject.png]]
The parameter can be found in '''Entity/Mesh object component/LOD Factors'''.<br>[[File:armareforger_levelofdetail-meshobject.png]]


There needs to have as many "LOD Factors" as there are LODs in XOB model, which are inserted in Mesh object component, in order to influence all the LODs. The good news is that the number of factor fills in automatically based on the number of LODs in the inserted XOB model. Each factor corresponds with respective LOD, so factor 3 influence LOD3 and so on. When there is less factors than there is LODs in a model, then these LODs, which don't have their factors assigned are simply not affected at all....or they simply behave like if the factors for them were set to 1. As multiplying by 1 means no change.
There needs to have as many "LOD Factors" as there are LODs in XOB model, which are inserted in Mesh object component, in order to influence all the LODs.
The good news is that the number of factor fills in automatically based on the number of LODs in the inserted XOB model. Each factor corresponds with respective LOD, so factor 3 influence LOD3 and so on.
When there are less factors than there are LODs in a model, then these LODs, which do not have their factors assigned, are simply not affected at all...
or they simply behave like if the factors for them were set to 1 - as multiplying by 1 means no change.


[[File:armareforger_levelofdetail-lodfactor.png]]
[[File:armareforger_levelofdetail-lodfactor.png]]


An important note is that '''LOD Factors are inherited from parent prefabs to children prefabs''' as all the other mesh object component parameters. So it is possible to have some factors setup for the "base" or "core" prefab, which fits most of the prefabs inheriting from it. Yet there is always the possibility to not inherit and to change the factors for any specific prefab/entity in the prefab hierarchy.
An important note is that '''LOD Factors are inherited from parent prefabs to children prefabs''' as all the other mesh object component parameters.
So it is possible to have some factors setup for the "base" or "core" prefab which fits most of the prefabs inheriting from it;
yet there is always the possibility to not inherit and to change the factors for any specific prefab/entity in the prefab hierarchy.


=== Save Process ===
=== Save Process ===


Saving of the LOD Factors is done the same way as any other parameters are saved on entity components. Anyway here is a guide for the saving process just in case:
Saving of the LOD Factors is done the same way as any other parameters saved on entity components. Here is a guide for the saving process just in case:


The LOD factors for specific prefab can be saved by:
The LOD factors for specific prefab can be saved by:


# changing the factor values on "Entity instance" placed in map, applying them to specific inherited prefab by "Apply to prefab" button and then save the world... which saves also all changes in prefabs. <!--
# Changing the factor values on "Entity instance" placed in map, applying them to specific inherited prefab by "Apply to prefab" button and then save the world... which saves also all changes in prefabs. <!--
-->Just be aware that this applies all the parameter that you changed on the mesh object component so be sure have not touched anything else on the Entity instance.
-->Just be aware that this applies all the parameters that you changed on the mesh object component so be sure have not touched anything else on the Entity instance
# selecting specific inherited prefab first (on the Entity instance placed in map), then changing the factors values and saving the world.
# Selecting specific inherited prefab first (on the Entity instance placed in the world), then changing the factors values and saving the world.




{{GameCategory|armaR|Modding|Guidelines|Assets}}
{{GameCategory|armaR|Modding|Guidelines|Assets}}

Latest revision as of 12:48, 16 November 2023

Basics

Level Of Detail (LOD) in words one LOD or more LODs (LOD0, LOD1 - LODn) are versions of a model with specific triangle and shader complexity. The lower the LOD number is the better the quality/higher complexity is. LOD0 stands for the nicest and most performance heavy one. Then the higher the number, the less complex and often also worse looking the model is.

These performance-cheaper model variants (all but LOD0) are to be rendered generally at higher distances in order to save performance on the GPU. The closer the LODs are rendered, the more GPU performance it saves. A user who will set lower quality in Settings/Video/Model geometric detail in the game's options will get closer switching to worse LODs to save more performance.

How to set which model part will be part of which LOD is described elsewhere (FBX import), but generally put the _LODn suffix into object name inside FBX.


Preview

How each LOD is looking, what materials they have and how much triangles or vertices they have can be directly checked in Workbench. Just find the desired XOB model in the Resource Browser and double-click on it. Then check the Details tab on the right part of the viewport and open its LODs sub-tab. Then, if "Force selected LOD to render" is checked, it is possible to scroll through the LODs and actually see them.

armareforger levelofdetail-preview.png


Debug

There is a diagnostic tool which tells which LOD is currently visible on any visible entity instance in a map in World editor. Turn it on with the Diag Menu by pressing Alt + ⊞ WinScene/Colorize objects LODs. Now each LOD except for LOD0 will have color overlay. If no other than LOD0 is present for the object, then it will constantly switch all colors.

no color overlay ...
LOD0 LOD1 LOD2 LOD3 LOD4 LOD5 LOD6 ...


Automatic System

Why an automatic system, when other engines offer manual control of LOD behaviour? The automatic system is much less prone to human error and always ensures LOD functionality, even though it might not be always ideal. For these "not ideal" cases there are manual overrides which will be presented later.

The LOD system tries to keep a constant triangle/pixel ratio across the screen. It is possible to estimate LOD distances considering LOD factors as a multiplier of triangle count that will change the system's behaviour into earlier/further LODing distance.

LOD0 - LOD1

When the model switches from LOD0 to LOD1 (generally begins to switch LODs) depends on several parameters:

  • Spherical size of the object - the larger the object is, the further away it starts to switch to worse LODs
    armareforger levelofdetail-boundingsphere.jpg
  • Triangle count of LOD0 - the more triangles the closer it starts to switch to LOD1
    armareforger levelofdetail-trianglecount.png
  • Field of View (FOV) - the larger FOV the closer it starts to switch to worse LODs
    armareforger levelofdetail-fov.png
  • Graphic settings - "Model geometric detail" on Ultra results in switching to worse LODs further away, Lowest vice-versa
    armareforger levelofdetail-model-geometric-detail.png
LOD1-2-3 size and triangle count

LOD1 - LOD2 - LOD3+

When the model starts to switch from LOD1 to LOD2, LOD2 to LOD3 and so on depends on two criteria:

  • The LOD switch happens roughly when the spherical surface size of the currently loaded LOD on the screen reaches half the size compared to the moment of its first appearance, and the same goes for the next LOD. "Roughly" because it also depends on the other criterion:
  • Relative triangle count between LODs - when each LODs have exactly half the triangle count of the previous one, then the first rule based on surface size applies exactly. When the relative triangle count is not done more or less by half, then it might switch a lot sooner or later.

    Sometimes the LODs are not switching ideally. To save the most performance and get the most from LODs, there are manual overrides.

Manual Override

The "triangle count" parameter, which heavily influence how fast or slowly prefab is LODing, can be overridden with "LOD Factors".

Yet it multiplies it only for the LOD switching behaviour and it is not really increasing/decreasing number of triangles in the model. By setting it, it just forces the specific LOD to remain in the scene for shorter (more triangles) or longer (less triangles) distance from the camera until it switches to the next LOD.

The parameter can be found in Entity/Mesh object component/LOD Factors.
armareforger levelofdetail-meshobject.png

There needs to have as many "LOD Factors" as there are LODs in XOB model, which are inserted in Mesh object component, in order to influence all the LODs. The good news is that the number of factor fills in automatically based on the number of LODs in the inserted XOB model. Each factor corresponds with respective LOD, so factor 3 influence LOD3 and so on. When there are less factors than there are LODs in a model, then these LODs, which do not have their factors assigned, are simply not affected at all... or they simply behave like if the factors for them were set to 1 - as multiplying by 1 means no change.

armareforger levelofdetail-lodfactor.png

An important note is that LOD Factors are inherited from parent prefabs to children prefabs as all the other mesh object component parameters. So it is possible to have some factors setup for the "base" or "core" prefab which fits most of the prefabs inheriting from it; yet there is always the possibility to not inherit and to change the factors for any specific prefab/entity in the prefab hierarchy.

Save Process

Saving of the LOD Factors is done the same way as any other parameters saved on entity components. Here is a guide for the saving process just in case:

The LOD factors for specific prefab can be saved by:

  1. Changing the factor values on "Entity instance" placed in map, applying them to specific inherited prefab by "Apply to prefab" button and then save the world... which saves also all changes in prefabs. Just be aware that this applies all the parameters that you changed on the mesh object component so be sure have not touched anything else on the Entity instance
  2. Selecting specific inherited prefab first (on the Entity instance placed in the world), then changing the factors values and saving the world.