plane icon Welcome to Microsoft Flight Simulator’s SDK Q&A Platform!

You have questions regarding the SDK? DevMode Tools? SimConnect? You would like to submit an idea for future improvements, seek help or exchange knowledge? You’re in the right place.


Please take a moment to read the platform’s guidelines before you get started!


question

tsgucci avatar image
tsgucci asked rhumbaflappy answered

Why to resize textures on lower LOD if MipMaps are present?

I'm working on the optimization of my objects using the statistics profilers and reading the SDK relevant section. Both encourages us to use smaller textures on lower lods, even 64x64 pixel sized textures on the LODs which are less than 5%.

Is this really needed? I have checked the converted DDS textures. They all contains MipMaps. Are the mipmaps ignored by MSFS?

I'm just asking if this really neccessary to define almost for each LOD a new material and to add additional textures increasing the overall loaded material and texture numbers.


Thanks a lot!

scenerymodeling
10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

OptimalCoyote89 avatar image
OptimalCoyote89 answered OptimalCoyote89 commented

Hi,

Using lower-resolution textures is not to reduce texture sampling cost, it is to reduce overall memory usage. It is theoretically possible (albeit rather complex) to dynamically stream the required mipmaps from disk, but this is not a feature we have at the moment.

For memory optimization, there are a few key elements:

  • it is important that lower resolution LoDs use less memory
  • multiple (or even all) LoDs may be loaded and displayed at the same time, thus exist in memory at the same time

Consider two different cases.

  1. You have a model which exists only once in the world. In this case, only one LOD will persist in memory. To facilitate fast loading/unloading of the model, it helps if the textures are shared between the LODs. For memory purposes, this is not as important, but it can still help to reduce memory spikes when streaming in LODs.
  2. You have a model which exists multiple times in the world. Think of multiplayer aircraft, or props such as lanterns. In this case, multiple LODs may persist in memory (the model can be displayed far away and close by at the same time). To reduce the total memory footprint, it is crucial that textures are shared as much as possible between the LODs. At the same time, if the model is only displayed once, but far away, you want a small memory footprint. If vertex coloring does not cut it, and you need a texture for a faraway model, having a small texture (instead of some 2k maps you may have) can help reduce memory usage.

A final note. You say: "to create additional materials and textures for each LOD leads to a contradictory effect in optimization". In reality, due to the way our engine (and the LOD system) works, materials are not shared between different LODs, only textures. As you say, to create additional textures seems contradictory. I believe duplicating textures should only be done if texture memory for a given LOD can not be reduced through different means. For example, simply by removing textures from a material, or using vertex colors. Vertex color is great, as it is practically free.


In the documentation, it currently says:

Prefer low-resolution textures for LoDs below the approximate 5% "minSize", eg: try to keep this as 64x64px or smaller.

We will change this to be a bit more clear on the intention behind it:

When reducing texture memory for lower resolution LODs, if it is not possible to remove more textures, use lower resolution textures instead (and make them small, e.g. 64x64px or smaller).

2 comments
10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

tsgucci avatar image tsgucci commented ·
Thanks for your answer!

If I understand it well the main object should be to reduce the memory used by textures.

Just to clarify when I talk about textures I always mean base color texture.

For me a crucial question here if the texture gets unloaded from the memory if it is not used at the scene at the moment?
What I mean by that if I add a separate lower res texture to a smaller LOD but the view comes closer and larger LOD with larges texture gets loaded is the smaller res texture unloaded from the memory?

0 Likes 0 ·
OptimalCoyote89 avatar image OptimalCoyote89 tsgucci commented ·
yes, the smaller resolution texture will be unloaded if it's not used by another instance of your model or by another model
1 Like 1 ·
tsgucci avatar image
tsgucci answered tsgucci edited

I have made a small experiment. I have opened one of my converted DDS texture in the package. Edited only the 2nd mipmap (some red criss-cross) with GIMP and saved it.

It does seem that the MipMap is indeed used in the simulator and working fine. Nice smooth transitions from far to close rendering.

Look at the screenshots. The red "scribbling" appears only at a certain distance.

I think it is crucial to make a statement on this matter because in my opinion to create additional materials and textures for each LOD leads to a contradictory effect in optimization.

1625747025417.png

1625747045147.png




1625747064180.png



1625747025417.png (493.0 KiB)
1625747045147.png (3.5 MiB)
1625747064180.png (4.4 MiB)
10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

rhumbaflappy avatar image
rhumbaflappy answered OptimalCoyote89 commented

I would think replacing textures with colors would be best for the more distant LODs if possible.

1 comment
10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

OptimalCoyote89 avatar image OptimalCoyote89 commented ·

absolutely :)

as I said in my answer: "duplicating textures should only be done if texture memory for a given LOD can not be reduced through different means"

"different means" including vertex color, for sure!

0 Likes 0 ·
rhumbaflappy avatar image
rhumbaflappy answered

I see the default POI objects in the sim do not use smaller textures for different (smaller) LODs. But this might make sense as they are placed once in the sim as noted above.

  1. You have a model which exists only once in the world. In this case, only one LOD will persist in memory. To facilitate fast loading/unloading of the model, it helps if the textures are shared between the LODs. For memory purposes, this is not as important, but it can still help to reduce memory spikes when streaming in LODs.
10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 5 attachments (including images) can be used with a maximum of 19.1 MiB each and 23.8 MiB total.