ULS : Universal Level of Detail system

RELEASED:
Pro version: http://www.unity3dx.com/index.php/products/uls-pro/
Free version: http://www.unity3dx.com/index.php/products/uls-free/

The idea was to make a LOD system that is blazing fast, uses almost no CPU, and can be used on any type of GameObjects.

While I was doing a forest pack (not finished yet) I came with the idea that in order to have something that is working smoothly on iPhone and is taking as low CPU as possible, I should not have a main manager that calls all the LOD objects, but rather have each object that are like a little robot managing its own LOD.

You need to create a special GameObject that will includes all the different LOD. Each LOD can be any kind of prefab. In the example of the video, the 1st LOD is a prefab with a rounded box of 500 polys, a spotlight with flare, and it catches and receive shadows. The second LOD is a prefab that has no spotlight and caches shadows. The last one is a simple 86 polys box that has no shadow.

Everything is possible and each LOD prefab can be anything. Buildings, trees, spaceships with projectors and lights… anything.

Each Object is prepared by an Editor Script. The editor script will set some variable, like the number of frame the object will check itself, add the necessary scripts, the distances for each LOD, and eventually the wind, or any specifc value. After that, each object is independent and is taking care of itself. The manager can instantiate or erase the LOD pre-generated. Once done you can save your project and all the LOD clones can be moved, and arranged the way you want. When you run the program, each clone will act by itself and optimize its display. The result is really fast even on iPAD 1.

In this video an equivalent to 20 Millions poly are displayed, 37500 objects, each with the LOD script attached, around 4000 spotlights with flare, shadows, collision (you can see that the sun hides behind the cubes), the first LOD is a rounded cube of about 500 polys. I get more than 40 FPS (average 50 FPS) when I do not record the video.
My setup is a Laptop with I7 720 CPU and Geforce GTX260M.
The system is working on iPad/iPhone, I am working on another video specific to these platforms.

Looks very nice :slight_smile:

Indeed… You have a potential customer. :wink:

Very nice work.

I thought this almost exact system was about to be built into Unity, the Ninja Camp video showed it running, or was I mistaken?

NO, it is not the Ninja Camp thing…I am quite sure that the LOD groups will not give you anything close to ULS, even if it is better than what we had before… Ninja Camp uses the common approach that is to have different mesh stored and a general manager that switch them depending on the distance from the camera.(tell me if I am wrong), also creating the groups seems a bit of a hassle.

My LOD system is totally different.

First, it uses Prefabs. LOD is not only about the number of polygons. Why would you have animated character at far distance? If you have a spaceship close with lights in the reactors, why the one far away would carry the light too? And do you need to have these far trees to have collision with anything?

ULS allows you the ultimate flexibility to assign whatever you want to your prefabs and display them with LOD, not only the mesh.
Also ULS do not run a manager that is checking the LOD of all the objects, but an editor script that scan all the LOD objects with the push of a button and will precalculate whatever each object needs to take care of itself, so that the LOD script that is attached to each object is doing almost nothing and is running really fast.

My approach to the LOD optimization is to pre-calculate in the Editor all the LOD objects and give them a total autonomy.

This has a lot of advantages:
1- you do not have a spike when the LOD manager is running, each LOD object will check his status at a random interval precalculated by the editor script for you.
2- there is no manager that ‘blocks’ the processing and make the iPhone/iPad exit like other LOD system. iPhone/iPad are sensitive to any slow down and if one function is taking too much time, Apple exit the Application. This cannot happen in any cases with ULS.
3- Each LOD object is a prefab, that makes it easy to copy, make different versions to test the speed of this prefabs.
4- ULS uses only prefabs as I said before, it is possible to ajust all retails, including multiple objects together, mix of flares, particles, shadows, collisions etc…
5- ULS uses tags to manage the differents LOD object, for example grass would be “LODGRASS”, trees “LODTREES” etc… this make easy to fold, erase, update, save in a prefab all the LOD object instantiated.
6- ULS do not instantiate the objects at run time, but in the editor. Once instantiated, you can manipulate the LOD objects, erase, move, plants, etc… but at run time, the LOD objects are loading ready to run, no long and timely initialization is needed.

I will soon release content packs ULS ready, that means that they can be instantiated with ULS and will manage their LOD by themselves. The first package will the 10 autumn forest trees.

Splendid. How many lines is the code? How long did you spend developing and testing it.

What you describe is pretty easy to do after some study and has been discussed with exactly this design on these very forums in the past. I am sure you read the very same articles on this forum we all did when designing lod scripts.

By the way, i am using exactly this setup with prefabs and scripts that run themselves via coroutines that randomize themselves to avoid synchronization and try to do little heuristic to predict when the player moves to relevant boundaries.

If you try to sell it, please go ahead, but include commented code with ample documentation, not Unity like mockumentation.

Problem is, that such system should be in core from the beginning. Not let people to design it by themselves, because everybody have to do it again and again. But no, some manager decided, that stupid fancy effects like deph of field are bigger seller. For any Unity programmer, who knows how Unity works is such system piece of cake. And his one day of work will save thousands of work-days of other people. Everybody who made any game with unity probably have some LOD script of his own. Silly.

/signed

I did it for the Speed forest pack I will be releasing soon. I realized that it should be useful to make it not only for trees, so I have created an editor script to ease the LOD prefabs instantiation, and step by step here we are. Hard to say how much time, not much.
About the line of code, the LOD script is really small. It should not be big, anyway everything is supposed to be precalculated by the editor. The LOD script just check where it is and what LOD it should be.

I do not use coroutines. Nothing else than a one page LOD script is necessary to run for each prefab once they have been ‘prepared’ by the editor. It is a work I can compare to what I was doing with Atari long time ago. You try to pre-calculate everything so that at the execution time, each prefab runs 1 or 2 ‘if’ no more. Then it is really fast. The only thing I cannot precalculate is the distance between the camera and the prefab, but I can spread this on several frames so that at the end the cost is nothing.

I think the interest of this LOD system will be to be used with content packs I will release later. So that you do not have to work on the LOD, you just instantiate a prefab with ULS and that’s it.

Sorry, but I don’t really understand what’s the competitive advantage here.

From what you say, it seems to me that you assign a scipt to each “LODed” prefab which activates/deactivates the relevant LOD object (and - I may add - could possibly enable/disable the other scripts running on this prefab, to gain some more processing cpu per frame) - all these based on distance from player/camera.

Then you precalculate bake all distances to a (builtin?) array (for speed).

And, unless this routine is spread to several frames, there is a cost of running all this for several gameobjects in the same frame.

Is there something that I miss here?

I would love to check this out. How far is this from beeing released.
Could you upload a video of the workflow of your lod system?
How much are you charging for this asset?

It will be free and will be released next week.

@immFx: you will see when it will be released, if you can optimize better let me know I will add your changes and credit you. I think this is the fastest way to do LOD and as well the most easy/convenient.
But I can be wrong. I hope everyone will use it.

Kudos for freely releasing it to the community! I will definitely check it out!

WoW!
And it will be free?!
I’m sure this will help me and the community a lot…thanks,unity3dx!

This will be a big help for our project, thanks for sharing with the community.

any news on this?

Yep, almost ready, I was busy on Smart water for mobile. I should release it within 48h. I will post here when ready on http://unity3dx.com

Any infos abot the release of your lod system?

Has this been released yet?