---
description: Information on sections in MLOD P3D files, supplementary to the community wiki
---

# Sections

{% hint style="info" %}
This page is meant to supplement and clarify certain informations written on the [community wiki](https://community.bistudio.com/wiki/Section_Count) about model sections, prior knowledge of that article is required.
{% endhint %}

## Definition correction

### Community wiki definition

According to the community wiki:

> A section is essentially a combination of material and texture, which contains one specific shader, with it is specific settings and maps.

This definition is mostly correct, but doesn't explain the phenomenon of section duplication (indicated in the Resource Library of **Object Builder**), which is often deemed to be a bug by modders (this doesn't seem to be the case).

<figure><img src="https://3093199008-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FW202g4rqtsk2O6cTvlfr%2Fuploads%2F78sKcPSXyzvvrkrWSQ6G%2Fimage.png?alt=media&#x26;token=7a719915-41ad-45e4-9429-bafe667b1046" alt=""><figcaption></figcaption></figure>

When this happens, **Object Builder** displays multiple instances of the same texture-material pair as separate sections, with different face counts assigned to them. The community wiki definition offers no explanation for this.

### More accurate definition

After some testing, it's clear that the section duplication shown in the above example is because the sections are mixed together in the face list of the P3D LOD.

<figure><img src="https://3093199008-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FW202g4rqtsk2O6cTvlfr%2Fuploads%2FhcYcHJsetipVexXiM0X0%2Fimage.png?alt=media&#x26;token=be833404-5df6-484d-876b-ea77e07bf3f6" alt=""><figcaption><p>Mixed sections in a P3D LOD, texture+material on left, number of assigned faces on the right</p></figcaption></figure>

Therefore perhaps a better definition would be:

> A section is a collection of faces in a P3D LOD, using the same texture+material pair, and written contiguously in the face list of the P3D file.

## Section fragmentation

In the MLOD P3D format the mesh faces are stored in a list. Each face definition contains the path to the assigned texture and material file.

{% hint style="info" %}
For more info on the P3D format, read the [community wiki](https://community.bistudio.com/wiki/P3D_File_Format_-_MLOD#MLOD_LOD).
{% endhint %}

Suppose we want to have a simple cube with 6 faces, and 2 materials (3-3 faces each).

Ideally, every face belonging to the same texture-material pair should be written contiguously in the file. This would result in the lowest number of sections, 2 in this case.

<figure><img src="https://3093199008-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FW202g4rqtsk2O6cTvlfr%2Fuploads%2Fn1PEexQQKImWo9Oks9yW%2Fimage.png?alt=media&#x26;token=3f6d0e64-dffd-4c76-b0d8-03779bc31d3a" alt="" width="375"><figcaption></figcaption></figure>

However, if we copy-paste geometries in the LOD in **Object Builder**, or a 3rd party software of our choice doesn't group the faces based on their materials during exports, the face list may become fragmented. In this case the faces otherwise belonging to different sections end up being mixed after one another. This leads to more sections. In the worst case scenario (when faces from different sections are alternating one by one), it may lead to almost as many sections as faces, 6 in our example.

<figure><img src="https://3093199008-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FW202g4rqtsk2O6cTvlfr%2Fuploads%2FjTui6Y6n1lLKX8fYgeKS%2Fimage.png?alt=media&#x26;token=95e8cb3b-964a-4141-b984-f32b30e19ad2" alt="" width="375"><figcaption></figcaption></figure>

{% hint style="info" %}
How much this is optimized during coversion to ODOL format is not certain, but inspection of files shows that fragmentation might not be reliably resolved during the process, especially considering the issue of alpha face order.

A model with 13 sections (originally 5, if it wasn't fragmented) ended up with 7 sections after the conversion to ODOL, according to Mikero's [Eliteness](https://mikero.bytex.digital/).

![](https://3093199008-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FW202g4rqtsk2O6cTvlfr%2Fuploads%2FhcYcHJsetipVexXiM0X0%2Fimage.png?alt=media\&token=be833404-5df6-484d-876b-ea77e07bf3f6)![](https://3093199008-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FW202g4rqtsk2O6cTvlfr%2Fuploads%2FXvcgPBkwDXTtl3EZULSW%2Fimage.png?alt=media\&token=d044d137-9430-4a16-8676-c940959c4137)
{% endhint %}

### Section sorting

Since the section count tends to have a significant impact on performace, it's important to minimize it. When using tools to export to P3D format directly, we should use one that makes sure the sections are not mixed together (like the [**Arma 3 Object Builder**](https://mrcmodding.gitbook.io/arma-3-object-builder/home) for **Blender** by me), or use the sorting option included in **Object Builder** itself (`Faces >> Sort`). This will collect the faces belonging to the same texture-material pair, and reorder the face list accordingly.
