1
\$\begingroup\$

There are many Unity assets that create simplified LOD's for many complex or big meshes. This LOD technique will make the apps run faster and more efficient.

I am new to Unity and LOD. So, I am curious about how LOD works. (I am sorry if my questions are too basic and not interesting.)

Here is the situation:

Suppose I have a BIG mesh with 20,000 triangles. Then, I use a Unity asset to create 3 LOD's for this BIG mesh. My questions are:

(1) If I generate 3 LODs for my original FBX (as mentioned above), does this mean this Unity asset will generate 3 separate FBX files for these 3 LODs, and store these 3 FBX files into my project, which will increase the size of my project (and APK) ? (Or they don't actually generate 3 physical FBX files for these 3 LOD's ?)

(2) If the answer to question (1) above is that the Unity asset actually generates 3 separate FBX files for these 3 LOD's, then I would like to have this next question: If I generate 3 LODs for my original FBX, can I only keep and store ONLY the "LOD 2" to my project and use ONLY this "LOD 2", and then delete "LOD 1" and "LOD 3" ?


PS: For example, here is the link to one of the Unity assets that simplify the BIG meshes:

https://assetstore.unity.com/packages/tools/game-toolkits/ultimate-lod-system-mt-automatic-lod-generator-mesh-simplifier-m-170425

NOTE: Please note that I am not affiliated with this Unity asset in any way, shape or form. I am not promoting this asset. I am only learning about how LOD works.

\$\endgroup\$

2 Answers 2

5
\$\begingroup\$

Unity doesn't generate FBX files. The Unity Editor lets you import FBX files, which Unity converts into its own propriety file formats when you build your game.

Each LOD is a separate mesh and will use some GPU memory at runtime. Normally, LOD meshes are included with the build and will increase the amount of storage space that the game uses.

It is possible, with your own code or with a third-party asset, to generate LOD meshes at runtime, which would mean that they only consume memory and not storage space. However, this is approach is usually not recommended, because generating an LOD dynamically has a high performance cost and will (depending on how your game is built) either increase load times or cause stutter during gameplay.

It is usually not worth worrying about how LOD meshes will affect the size of your build. Meshes typically range from a few kilobytes on the simple side to a few megabytes on the complex side. Usually it's textures, audio, and video that make up the vast majority of your build size.

The file size of an FBX file does not necessarily reflect the size of the mesh data in the FBX. If an FBX file that you want to import into Unity is more than a few megabytes, this may mean that there are textures embedded in the FBX. Expand the FBX in the Unity Editor's Project panel to see the meshes, materials, and textures that are contained in the FBX. Unity will separate the textures from the mesh data in your build.

Particularly on mobile, you should not be generating LODs dynamically at runtime just to slightly reduce the size of your build. If your build is too big, you should start by optimizing your textures and audio:

  • Look at your build log to see which files are making the biggest difference in your build size.
  • Make sure that your textures are all compressed. Check for issues which may disable compression, like textures with mipmaps that aren't Power-of-Two (PoT) sizes.
  • If necessary, reduce the resolution of large textures
  • If necessary, reduce audio file sizes by changing the audio format, converting from stereo to mono, reducing audio quality, trimming silence from the beginning or end of audio clips, etc.
\$\endgroup\$
2
\$\begingroup\$

Suppose I have a BIG mesh with 20,000 triangles. Then, I use a Unity asset to create 3 LOD's for this BIG mesh.

Let's do a back-of-the-envelope calculation of how much data an alternative LOD for a mesh could consume. Let's say you are going to take this 20,000 triangle mesh and generate a 5.000 triangle mesh from it. How much data could that be? Let's assume the worst case that

  • No shared vertices, so every triangle is 3 vertices. Which means we have 15,000 vertices. No, this is not realistic, but we are assuming the worst case here.
  • Each vertex has a position. A position is 3 values (x, y and z) and each value is a 4byte float. So 12 byte per vertex. Those are 180 kByte for vertex positions.
  • Each vertex might have a vertex normal, which would be another 3 floats, so another 180 kByte.
  • Each triangle corner will have a UV coordinate pair, which are two additional floats per vertex, so another 120 kByte.
  • Each vertex might have a vertex color (if you are using those - you might not, especially when the model is already textured). Which are up to 4 byte, or another 60 kByte.

So summing it all up, we got about half an MB for this LOD. Incrementally smaller LODs will have proportionally less data. Having less data than the original is the point of having LODs, after all.

Now you might wonder: "But what about the textures? Aren't those often a huge part of the data footprint of a 3d asset?", well, there really is no reason not to reuse the textures of the full-scale asset. Especially if you enabled auto-generation of MIP maps. Then you already have lower-resolution versions of those textures in memory anyway.

Another thing we didn't account for are animations. You didn't mention if the mesh you are trying to simplify uses animations. But let's say it does.

I doubt that a tool to automatically create LODs will touch the armature. There is just too much that can go wrong with automatically removing bones. And adjusting animations automatically to still work with a reduced armature would also be rather adventurous. So armature and animations will probably be reused from the full-scale model. However, what we do need to account for are vertex weights for each bone. This could actually be quite a lot of data when the model has a lot of bones. 100 bones with 4byte weights for 15000 vertices would be 6 MB.

But speaking of animated meshes, and characters in particular: This is one area where it can really pay off to generate your LODs manually. For example, a low-level version of a character often doesn't need finger-bones and facial rig. Omitting those from the lower levels can save you a ton of performance.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .