SimpleLOD user support thread

Hi everyone,

For my own project I will allow endusers to upload their own 3D models. But these models are bound to be immense in terms of number of vertices and triangles. Some of them will have to be reduced, all of them will need reduced LOD levels for distant viewing and most of them will need many sub meshes to be combined.

Since many developers run into the same problems when they download some model from the internet or the asset store that often contain way too many vertices for its purpose, I decided to turn the programs into a package.

SimpleLOD will combine the meshes of all child objects in 1 mesh with a submesh per shared material. You can then reduce the number of triangles by setting the compression level.
With 1 click you can generate 3 LOD levels and add a LODSwitcher component to your gameobject. This way any gameobject (skinned meshes as well) can be made LOD ready.

There are many mesh combine packages, but most of them do not support skinned meshes. SimpleLOD does support skinnedmeshes. So you can have an avatar model, several clothes meshes and several items that will all be combined into 1 skinned mesh, provided that they all use the same skeleton.

Of course there are also very good alternatives that generate your LOD meshes. But SimpleLOD produces very good results, supports skinned meshes, contains all source code, has no DLL’s and uses no external services.

And of course the end result will be better when you model everything by hand.
But not everyone is a master 3D modeler and not everyone can afford those programs. This package is for those people that want an easy solution for a complex problem.

When you want to use it at runtime (like I do) you can make use of the GameObject extension methods:
myGameObject.CombineMeshes();
Will combine all meshes in all child gameObjects into 1 mesh with submeshes for each unique shared material.

myGameObject.SetUpLODLevels();
Will create 3 LOD level meshes, add a LODSwitcher component and make your gameobject ready to go. Optionally you can set compression levels and switch distances

myGameobject.SetUpLODLevelsAndChildrenWithLODGroup()
If you prefer to use Unity’s LODGroup component instead, this method will set it all up for you.

The mesh compression algorithm is described here
The documentation can be found here
The webplayer demo can be found here
The asset store package can be found here

Simple LOD runs entirely inside Unity. The source code is all included and written in C#. There are no DLL’s or hidden stuff.

Note: Reducing triangles is a complex process and is bound to take some time, varying exponentially from a few milliseconds for small meshes up to several minutes for meshes with 64K vertices. This action is only needed once, since the reduced mesh is stored in your project folder.




1 Like

The following question reached me on Facebook: You can put in the plugin SimpleLOD a simple bar that simplifies a model for Number of triangles instead of using a number as now?

This is a good suggestion, but not very easy to achieve. In order to specify a desired number of triangles instead of a compression value, we’d need to compute weight values for each triangle (we do that now as well) and then order the triangles by this weight. Then remove / flatten the triangles in the order of their weight until the desired number is reached.

However, when you flatten 1 triangle, you immediately change the shape of the adjacent triangles. And so their weights need to be recomputed. The ordered list of triangles then needs to be reordered and things will become very slow.

Only by ignoring the effect to the adjacent triangles could this work, but that would have a negative effect on the quality of the end result.

Hello,
I just bought your Asset, and as I said you by email, I bought some Asset(drawcall pro, spritebaker) and I waste my time and money in $45 assets!!
So, I tried your Asset, and for moment I only use your CombineMesh, my drawcall was 195, and now I have 145.
Great product for moment, I will try your LOD system in few hours

Hey Menfou, I am about to lay the last hand on version 1.1
It is 3 times faster and the end results are much much better. If you send me an email i will send you this beta version. Because it may take a while before the update is in the asset store (review process and testing)

This goes for everyone that just bought SimpleLOD: If you want to try out 1.1 beta, send me an email with your purchase receipt attached.

Does this also Atlas the textures of all submeshes? Does it preserve animations of skinned meshes that are combined?

@Rajmahal , It does not make a Texture Atlas for you. If you want this, there are other good tools for that. It does merge the meshes of child objects into a single mesh, that contains a submesh for each shared material that was used in any of the children.

If you have a skinned mesh with animations, those will still work on the generated LOD levels for that mesh.

If you have a skinned mesh and a child object with another skinned mesh, you can merge those meshes into 1 skinned mesh, provided that they use the same bones. The animations will still work, but since the meshes are combined, you cant run an animation only on a part of the skinned mesh.

In the demo there is an example of Unity’s Ethan character (skinned mesh) that has separate sunglasses (also a skinned mesh). They are combined into 1 and Ethan LOD 0, 1, 2 and 3 can still run, but you can’t let him take off the sunglasses or make him wave them around, since the sunglasses have become part of the same mesh.

I tried your LOD system, and I can say it’s very easy to use, only 1 click to combine my house(50 gameobjects) , and 1 click to create 3 LODs.
In my scene I have 10 houses, I compared my scene with and without your SimpleLOD.

With SimpleLOD on my Windows Phone Mobile 28fps , without only 17fps.
On my computer 91fps with SimpleLOD, and 61fps without.
I see the Drawcall is highter with SimpleLOD , but the framerate is better.

I tried 2 Texture Atlas Assets, and I wasted my time and money because all 3D Assets I bought was not really well UV textured.

Wow! thanks for your support! I’m glad it works out for you. (It would really help if you’d give the product a few stars in the AssetStore)

But your game looks pretty good! I especially like the smoking buildings in the background and also fire bullet icon. The road that ends near the camera can probably be fixed by making the near clip pane of your camera a little smaller.

I see the drawcalls are indeed higher, which is weird, because when you render 50 gameobjects for 1 house, you’d expect a lot more drawcalls then with 1 gameobject. Unless all 50 gameobjects use different materials, in which case you end up with a mesh with 50 submeshes. And maybe you use occlusion culling? That might prevent a lot of those 50 gameobjects to be rendered, whereas you have 1 big gameobject now.

As for the texture atlas options: I think you are right and it would be a very good addition to the product. You could merge meshes, generate LOD levels and create texture atlases at the same time. That could totally work as a one stop for all option. Let me think about how to do that properly a bit. I will also try out a few 3rd party packages to see how well/poor they do their job. And I vaguely believe I read or heard something about this from Unity as well. It could be a 5.0 option.

A big gameobject can’t be batching.
It’s why the Drawcall increase.

Adding a texture atlas process to this would make this an insta-buy for me. Would love to have all that functionality baked into one. It would drastically reduce the time involved in my workflow.

This looks really nice, and fantastic price!

If I generate objects procedurally at runtime, say many different houses, could I then use this at runtime to get different LOD levels set up automatically for each house? I assume the performance is not good enough to generate it on the fly, but I was planning to do most generation in the beginning anyways and save the result. Unless it’s possible to run generation stuff in a separate thread or similar, but I know too little of that stuff. If the performance is not good enough, I might have to pre-build large chunks of buildings and generate their LOD in the editor in advance, but your tool would still be very useful.

Also, you mentioned skinned meshes. Do you think this would work with the UMA character creation kit for setting up LOD levels for their dynamically generated characters?

And one final question :slight_smile: Does it work with Unity Free, or does it require Pro?

Thanks, keep up the good work!

1 Like

@zugsoft Ah ok, you’re right
@Sir-Spunky I use this myself at runtime too. The user uploads a 3D model, I import it with SimpleOBJ or SimpleCollada and then automatically generate LOD’s for it. So yes, you could procedurally create houses and make LOD’s for them.
You can find a code example here
But beware that your houses are not too big (in nr of vertices) because for big meshes it may take a bit too much time to execute it. A small mesh with something like 5K vertices should be done in a second or so. This execution time increases exponentially when the mesh is bigger.
It might be faster to create LODs for chunks or for child objects first (as they are smaller en use exponentially less execution time) and then merge them together.
You can run it in a separate thread but it would still slow your game down.
I haven’t tested the UMA characters yet, but they should not give you any problems.
SimpleLOD should also work with Unity Free

1 Like

That’s great, thanks!

(If someone does test SimpleLOD with fully dressed UMA characters, please report back. It sounds like this should work, but UMA can be weird.)

1 Like

I tested UMA for you and it all worked fine. The UMA characters were created at runtime, so I couldnt use the editor tools and had to write a little script to reduce the meshes.
This is the script:

using UnityEngine;
using System.Collections;
using OrbCreationExtensions;

public class UMATest : MonoBehaviour {

    bool lodsMade = false;

    void OnGUI() {
        if(!lodsMade) {
            if(GUI.Button(new Rect(2,2,100,25), "Make LODs")) {
                CreateLODs();
            }
        }
    }
   
    void CreateLODs() {
        SkinnedMeshRenderer[] smrs = gameObject.GetComponentsInChildren<SkinnedMeshRenderer>();
        foreach(SkinnedMeshRenderer smr in smrs) {
            Debug.Log(smr.gameObject.name);
            smr.gameObject.SetUpLODLevelsWithLODSwitcher(new float[3] {0.4f, 0.2f, 0.1f}, new float[3] {0.5f, 1f, 1.5f}, true);
        }
        lodsMade = true;
    }
}

It took about 10 seconds to create 15 lod levels for 5 characters, compressing the meshes from 10K to 1.5K:

I didn’t try to tweak the compression values for optimal result, but this what what I got:

LOD 0: 10k triangles per character


LOD 1: 3.5K triangles per character

LOD 2: 2K triangles per character

3 Likes

just to confirm, i can use this at runtime, right? call it from scripts and such?

i have a need for a pretty simple mesh decimator, and this sounds about right. A lot of the others on the market seem to have way too many features (and too high a cost :p) for my needs and situation. I just want to remove redundant faces from pretty simple shapes

@Nanako Yes sure. Various methods are added to the default GameObject class. I just posted an example for the UMA avatars 1 post higher in this thread. There are also some examples in the online documentation
Let me know if you need any help.

SimpleLOD is now implemented in my own 3D website builder. Check out the blog post here: http://orbcreation.com/orbcreation/page.pl?1211
(Also uses SimpleOBJ and SimpleCollada for importing models and Texture2D Extensions for manipulating textures)

1882552--121083--Screenshot_2014-12-10_17-08-21.jpg

Nice model :slight_smile:

If a child transform had a negative scale, that part of the merged mesh would be turned inside out, because the triangles flipped over.
This is now fixed and submitted to the asset store for approval. Contact me if you don’t have the time to wait for asset store approval and I will email it to you.

1 Like