Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

【Optimizers】- Easy to use and functional components to optimize any other components!

Discussion in 'Assets and Asset Store' started by FimpossibleCreations, Jan 28, 2020.

  1. unity0106

    unity0106

    Joined:
    Apr 11, 2019
    Posts:
    4
    thank you
     
  2. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    348
    Updated to Version 1.0.3

    ● Important Change: Now "Deactivate Object" is not toggled by default, deactivating and activating whole game objects in many cases was causing performance peaks during culling object if it wasn't in camera view
    (if you rotated camera with 'cull if not see')

    ● Added "Auto" and "Set Far" button next to "Max Distance" it will help you define max distance for object, basing on camera's far plane settings, and size of detection sphere
    ● Automatic detection shapes dimensions now will fit better to scaled objects (when you're adding optimizer to object)
    ● Dynamic optimization method's detection shape (box) now scales with object
    ● Warning and explanation of "Deactivate Object" toggle in "Culled" LOD
    ● Warning message when you copy not prefabed objects or without shared settings with optimizers to another scene (LOD Sets will be lost - because they're managed by unity as scene assets, not gameObject serialized data)
     
    Last edited: Mar 11, 2020
    Unplug and dsilverthorn like this.
  3. Unplug

    Unplug

    Joined:
    Aug 23, 2014
    Posts:
    248
    i get these kind of console error
    "Culling group was not disposed. You have to call Dispose explicitly from the main thread. This will likely result in a crash.UnityEngine.CullingGroup:Finalize()"
     
  4. Unplug

    Unplug

    Joined:
    Aug 23, 2014
    Posts:
    248
    the optimizer does a lot more than what you are asking and it automate a lot of thing. You buy asset because you want to save time. Why spend countless of hours for something that is already done. sometimes you do sometimes you dont. That said, i'm giving you hint to what you can do for your situation and what you are asking look very simple to do by yourself and you could get more help on unity answer to avoid overflooding the forum here. what you ask take 10 lines of code max, be friendly and ask for help and people will give you help.

    be rude and youll end up buying a lot of asset
     
  5. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    348
    I can't reproduce it unfortunately.
    This message is logged when not calling .Dispose() on culling group before leaving playmode and all of that is done in OnDestroys() in code right now.
    I am not sure when and by what it could be interrupted.
    You do something specific when this error appear?
     
  6. Unplug

    Unplug

    Joined:
    Aug 23, 2014
    Posts:
    248
    after reading the patch note i have a question. If i have a prefab that i need to use in multiple scene. I have put the optimizer right on the prefab in the project browser (and not the scene object) Can i use that prefab in multiple scene ? (because the patch note mention something about not using the same object in multiple scene).

    The scene I got the error was producing other console log so it may be only a conflict. i have to test more and comeback with result. good support so far and thanks for the update. all improvement are welcome
     
  7. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    348

    "Warning message when you copy not prefabed objects"

    If you have prefab you can freely use it anywhere (LOD Set is saved inside prefab)
    same when you use shared settings (LOD Set from project directory)

    If it is not prefab (without shared settings) and you copy object between scenes, LOD Settings reference for optimizer will be lost, then you will have to select object on new scene and hit button "retry" in LOD settings view (settings will be resetted) but it's rather rare case.
     
    Unplug likes this.
  8. Aurigan

    Aurigan

    Joined:
    Jun 30, 2013
    Posts:
    263
    Hi there, have been playing around with this ... seems promising so far. I did have one nasty issue on getting started with it. I'm making a 2D tilemap game, by default the auto-created Optimizers Manager component somehow causes massive CPU overhead - I was getting 100's of ms from 'Others' in the profiler, reduced FPS to single digits. Selecting Dynamic Optimizing Setup/Advanced checkbox, setting the distance ranges much smaller then using the scene tools sync buttons solved this ... but I have no real idea what those did.

    Would be good to have this included in the setup doc / explained. Cheers!
     
  9. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    348
    Strange, I am sure game-mode code is not causing this, "Others" are things more for inside Unity Editor stuff.
    Maybe there was some exception error which was stacking itself or something else was causing this lag by coincidance.
    Hitting "Advanced" toggle is just showing more options in editor.
    I will analyze editor drawing methods to see if there can be something wrong.
     
  10. Aurigan

    Aurigan

    Joined:
    Jun 30, 2013
    Posts:
    263
    Yup, really strange ... it was reproducible by removing/re-adding Optimizers ... even without any active optimizers on any game objects the manager was somehow causing massive lag.

    Unrelated but also something to improve, maybe - the Sub-Assets Cleaner helper does work (by adding it after removing the optimizer) but not quite in the way I expected it to. If you add it while the optimizer is still on the game object it does nothing (which is fine), if you then remove the optimizer nothing happens (maybe it should? Then log a message, remove itself?) and then if you click 'check for leftovers' nothing happens (I'd expect this to remove the leftovers). Or maybe this should all just happen automatically on removing the Optimizer!
     
  11. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    348
    Cleaner component was created to remove sub-assets which was duplicated by some bug in version 1.0.1
    Right now this error occurs only sometimes and it's hard to reproduce, it is happening only on few unity versions,
    I just need more time to find best solution.

    Sub assets are cleaned by default when removing optimizer component, but when there are duplicates they aren't removed. Cleaner is removing this duplicates, I am not cleaning duplicates by default because in few versions of unity it was causing crash on my two computers (caused by simple AssetDatabase.ImportAsset(prefab)), I reported bug but without repro by unity bug team unfortunately, so it's too risky now.
    I am waiting for few improvements in assets pipeline by unity to have cleaner logics to do all this stuff, some things needed to be done in walkaround way to make system work.

    There was lately a lot of changes in prefabs, 2017 prefabs, 2018.3 prefabs workflow, 2019.3 asset pipeline v2, each thing needs it's own logics in some areas. 2017 for example is working without flaws but newest solutions limited some things and made things not so simple.
    The most safe solution is to use shared settings and save LOD presets in files inside project directory.
     
    dsilverthorn likes this.
  12. Aurigan

    Aurigan

    Joined:
    Jun 30, 2013
    Posts:
    263
    Ok, so at the moment, in Unity 2019.3.5f1, this shows an issue. If I add an Optimizer to a particle system prefab (in the project view, not while editing that prefab in the scene view), then remove it all of the sub-assets will still show as there in the prefab and Unity throws an `Assertion failed on expression: 'gForceReimports->empty()'` error.

    If I tab to another app then back to Unity the sub-assets are gone so I guess this is just a display bug, adding the sub-assets cleaner component also updates the project view ... so it *looks* like the sub-assets cleaner is required to remove the sub-assets currently.

    When switching to using shared settings all the sub-assets aren't cleaned ... so, in this case, using the sub-asset cleaner is actually required to tidy things up.

    Also, It would be neat if, when generating the shared settings the LOD levels didn't include part of the prefab name. If the prefab is called 'StunnedParticleEffect' the LOD Levels in the shared settings get called 'Stunn[Fparti]Culled' etc. As these are shared it would make sense just to have them called 'Culled', 'Hidden', etc.

    I also hit a small issue working with Optimizers/LeanPool (a Unity Asset store pooling plugin). An Optimizer on a particle effect will disable emission when out of range, if the GameObject with the particle system is then returned to the pool and reused the next time it's taken out of the pool the Optimizer won't re-enable emission even when it's in range. I'm hacking around this by adding a little script to reenable emission on spawning from a pool but ... maybe Optimizers should be setting LOD's OnEnable?
     
  13. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    348
    Yes, since unity 2018.X viewing true content of prefab needs asset reimport, refresh and sometimes something more.
    Cleaner is going through true content.
    There was more unknown errors like Assertion failed but after days and hours I solved almost all, but some things are still making life harder.

    It will be cleaned when you assign shared setting to "Shared LOD Set"
    But in next days I will check it all more with newest unity and asset pipeline v2.

    When optimizer goes from culled to another, it should enable emmission and render back, but if pool system is disabling it by itself there may be conflicts.
    Hard to tell, I would need to know a bit more about this pooling, I will check it soon.
     
  14. Aurigan

    Aurigan

    Joined:
    Jun 30, 2013
    Posts:
    263
    Thanks for the reply, all the pool system dies is de/activate the gameobject. I was still having issues with particle systems not showing up/restarting even with my hack to reenable the renderer so, for now, I'm giving up on using Optimizers, sorry to say it's caused a lot more issues than it's solving! Once the Optimizer is removed the pooled particle effects work perfectly, every time, again.
     
  15. Arsonide

    Arsonide

    Joined:
    Nov 16, 2009
    Posts:
    41
    Hello, me and my team are evaluating Optimizers for potential use in our project. In our project, performance is very important, and we've already been using camera frustum culling, distance checks, and the CullingGroup API as programmers, but we thought Optimizers might help our designers.

    However, upon importing the asset I immediately notice a few concerning things.

    Firstly, there are several "Resources" directories in the asset, these seem to be mostly used for demo purposes and example content, but these load into memory 100% of the time at runtime. Can all of these be safely deleted? We do not want any additional memory usage.

    Secondly, the Optimizers Manager singleton has a "magic getter" property that does some unnecessary and really intensive operations (like FindObjectsOfType). Really we just need a static reference that gets assigned on creation and unassigned on destruction, all of these extra searches are not necessary because we know only one will be loaded. Our scenes are pretty complex, so these searches take a while.

    This is kind of the extent of how far we can look into the asset right now, but I did want to share our immediate experience as other teams might have the same observations.
     
  16. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    348
    In resources there are important reference files for editor use.
    Folders like Editor/Resources are stripped from build.
    You can move "Optimizers/Resources" into any "Editor/Resources" directory and it should be not included in build.
    (it's about 9kb anyway, but if you don't want any files inside resources then go with editor/resources)

    FindObjectsOfType is called only in last case when script can't find Optimizers Manager.
    If manager is found once, this all things will not be called ever again if even called once.
    (When manager is created it becomes main reference, when reference is not null using "Get" returns it immedietely)
    FindObjectsOfType shouldn't be called ever (thanks to singleton) but it's added for total safety.
    You shouldn't worry about that ;)
     
  17. MegaCo

    MegaCo

    Joined:
    Jan 24, 2018
    Posts:
    83
    Hello, love Optimizers it's amazing! I just have a question my camera is added in runtime how would I use the optimizer manger to grab the camera.
     
  18. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    348
    You can call FIMSpace.FOptimizing.FOptimizers_Manager.SetNewMainCamera(yourCamera);
    from any script ;)
     
    dsilverthorn and MegaCo like this.
  19. MegaCo

    MegaCo

    Joined:
    Jan 24, 2018
    Posts:
    83
    I not the best at code, iv got a script working that adds the camera but I keep getting errors because there no camera set to the manger. When should I add the cam? also, I have the script on the camera should I have the script in the scene since the camera is only loaded when the game starts.

    thank you very much, sorry for the trouble :oops:
     
  20. psych77

    psych77

    Joined:
    Mar 1, 2017
    Posts:
    55
    Strangely i get lower FPS while using Optimizers than when im not using it, without quite understanding why. Using regular occlusion culling i get almost 100% better fps. Does it not like static objects very much? I put basic optimizer on every mesh renderer, set max distance to 50, and tried "effective" and "static", while having a optimizer manager where i tried different different world scales with little success.
     
  21. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    348
    I will make quick update to avoid spam of errors for not having camera in scene.
    Please mail me and I will send you quick fix to make it all work with your setup ;)

    Are you using "Deactivate Object" inside "Culled" LOD?
    Deactivating objects often takes some time for unity and it's better to disable just components.

    Using optimizers just on single meshes is not much help thought (unity is culling meshes outside camera view automatically - frustum culling) Package can give you best results when using on particle systems, lights or other visual effects.

    Using optimizers on groups of meshes can give benefits but I working on auto grouping feature for next versions because making groups by hand can be problematic.
    There also will be dynamic culling feature with multicore support which can be nice to use just with meshes.
     
  22. knas01

    knas01

    Joined:
    Feb 24, 2018
    Posts:
    150
    Hi. I wonder, does this asset work with 3rd party assets? I assume Optimizers smoothly disables components on gameobjects based on distance?
     
  23. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    348
    Yeah you can change any component's parameters basing on visiblity / distance.
    By default you can use optimizer on any monobehaviour but some variables like enums / vectors will not be supported to manipulate them, then you can create implementation script for custom monobehaviour / component, there is template where you have to do some basic value assignements in code and it will work.
    There is tutorial on youtube about making such implementation ;)
     
  24. knas01

    knas01

    Joined:
    Feb 24, 2018
    Posts:
    150
    Well I didn't get too much of the scripting thing, but as long it's possible I'm happy. I think it will be mostly used for lights and Visual Effect Graph stuff and I guess that would work pretty much automatic if I got it right.
     
  25. knas01

    knas01

    Joined:
    Feb 24, 2018
    Posts:
    150
    One more question; can this asset switch between mesh LOD levels created in other assets?
     
  26. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    348
    It's much better to use Unity's LOD Group component for that, but you could switch between separated mesh renderers in similar way, so yes you can.
     
  27. knas01

    knas01

    Joined:
    Feb 24, 2018
    Posts:
    150
    Thank you.
     
  28. MrIconic

    MrIconic

    Joined:
    Apr 5, 2013
    Posts:
    226

    Is this still relevant?
     
  29. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    348
    I was making fixes for that, and it was working, but I can't guarantee that there will be no problems, new prefab workflow is still lacking some functionalities to make prefab auto sub-assets management clean, but using shared settings provides flawless workflow it's just less comfortable (you need to save LOD files inside project)
     
  30. MrIconic

    MrIconic

    Joined:
    Apr 5, 2013
    Posts:
    226
    Good to know. Picked up some of these assets during the sale so I'll keep that in mind. Thanks.
     
  31. alex_1302

    alex_1302

    Joined:
    Aug 20, 2019
    Posts:
    26
    Hi. first of all, congrats. optimizer seems to be just that i need. I am very interested on it. i want to buy it, but i have a little question:
    i am working in a multiplayer fps project. and like you know, in multiplayer games you have more than a player located on differents places on the scene (terrain), but always with only one active camera. thinking on that i want to ask if your optimization tools can be used in my multiplayer, or is there some kind of optimization component no being able to be used on my multiplayer project ?.
    Thanks in advance. :)
     
  32. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    348
    When you play as client there is no difference, you optimize stuff around client camera, not for each other player.
    Other players optimize stuff around them on their computer machines, so I'm sure it can be used :D
    but hard to answer because I don't know what kind of elements you want to be optimized inside your project ;)
     
  33. alex_1302

    alex_1302

    Joined:
    Aug 20, 2019
    Posts:
    26
    Thanks for the fast reply.
    In my case i am interested in optimize the dynamic characters (npc's), let say with some kind of optimization like disable the rendering of far away or hidden dynamic objects (npc's enemies). i dont want to disable its controlling scripts, because an npc could be far away from a player but near other, by that, if i disable the npc controlling scripts they could be appearing 'freezed' for some player. i dont know if there are another optimization that could be applied. Other important thing is that the active camera needs to be setted at runtime because is inside the player avatar hierarchy and loading at runtime . i suppose that optimizer need to know the active camera in order to optimize the scene. How can i drive that ? is there some method to set the active camera if it change at runtime ? .

    Thanks in advance and have a nice day. :)
     
  34. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    348
    With optimizers you can select if you want to use lower quality skinned mesh renderer/disable it at certain levels,
    if you use foot ik scripts you can disable them too when characters are far. You can also select other components which are doing some calculations but are not needed when characters are far, it is up to you and up to your project ;)

    When you do it on server side then yes, but for client side you can do whatever you want.
    For example when other players are very far from npcs, then the npcs even can not exist on their clients, and be created only when certain distance is reached.
    If you're creating this multiplayer game with traditional logics then it works like that and you can feel free to hardly optimize everything on the client side (excluding only the most important stuff)

    You can set new main camera for optimizers with line of code like this:
    Code (CSharp):
    1. FIMSpace.FOptimizing.FOptimizers_Manager.SetNewMainCamera(yourCamera);  
     
  35. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    419
    Will "LOD Group" component provided by Optimizers work on tree planted with unity terrain? I know that Unity's LOD Group does work on those tree but will third party LOD switched work on them?

     
    Last edited: Apr 29, 2020
  36. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    348
    Unfortunately not, optimizers can change quality of whole terrain which is effective when you're using multiple terrain components.
     
  37. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    419
    So basically there's no way to change LOD bias for only trees planted with Unity terrain independently from global load bias that can be found in Unitys quality settings?
     
  38. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    653
    You could try applying Optimizer to the tree object and then when you paint it on the terrain, see if it works.
    I haven’t tried that one but I would think you could apply it to the prefab.
     
  39. therewillbebrad

    therewillbebrad

    Joined:
    Mar 2, 2018
    Posts:
    146
    Does anyone have some battle tested settings for a vr camera? My game objects are getting culled to agressively and not sure what the best settings are.
     
  40. OP3NGL

    OP3NGL

    Joined:
    Dec 10, 2013
    Posts:
    262
    does it work for VR?
     
  41. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    348
    It's highly dependent from your project's requirements. Please check scene view for gizmo guides.

    Yes it works for VR, but I would recommend using default single camera mode than per eye mode.
     
  42. AtomsInTheVoid

    AtomsInTheVoid

    Joined:
    Jul 27, 2015
    Posts:
    202
    Ok here's a question, not sure if answered before, but I'm particular interested in a Terrain LOD group. Not quite like how you had it in the video, what I want is a real terrain at LOD 0 and even 1, but then LOD 2/3/4 it would automatically flip to a MESH version of the terrain. Is that possible???? If not, CAN THAT BE?
     
  43. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    348
    Yes it is, there is last parameter in LOD settings called "Mesh Replacement"
    upload_2020-6-3_11-38-3.png
     
  44. AtomsInTheVoid

    AtomsInTheVoid

    Joined:
    Jul 27, 2015
    Posts:
    202
    Very nice!
     
  45. AtomsInTheVoid

    AtomsInTheVoid

    Joined:
    Jul 27, 2015
    Posts:
    202
    Just to confirm, does this work on editor mode too or just play/build?
     
  46. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    348
    Only Play/Build
     
  47. AtomsInTheVoid

    AtomsInTheVoid

    Joined:
    Jul 27, 2015
    Posts:
    202
    Why do you only allow for 4 LODs?

    Also, I need to set the LOD objects and settings from a C# script. How do you recommend I do that?
     
  48. AtomsInTheVoid

    AtomsInTheVoid

    Joined:
    Jul 27, 2015
    Posts:
    202
    upload_2020-6-7_21-51-6.png

    I've been hunting around your source code pretty deeply and it's a remarkable house of mirrors. I can't even search for the phrase "Mesh Replacement" and have it find the text, which feels impossible -- surely you must have typed that somewhere for the editor to know to write that?

    Anyway, what I'm doing it splicing up my terrains automatically, then creating MESH LOD's of several resolutions, but the last step is applying these LOD's to your LOD levels.

    This is about how far I've gotten:

    Code (CSharp):
    1.                 parentObject.AddComponent<FOptimizer_Terrain>();
    2.  
    3.                 FOptimizer_Terrain fop = parentObject.GetComponent<FOptimizer_Terrain>();
    It works, adds the Terrain Optimizer component.. but hunting around in 'fop' I can't for the life of me find the List that is storing the settings for each LOD. My best guess is something called ToOptimize but when I do fop.ToOptimize[0] I don't seem to get any of the options above, and certainly not the MeshReplacement variable I'm desperateiny looking for.

    Thoughts??
     
  49. AtomsInTheVoid

    AtomsInTheVoid

    Joined:
    Jul 27, 2015
    Posts:
    202
    Update: I tracked it down to a scriptable object named FLOD_Terrain.cs, and I can see the MeshReplacement variable there.. now I assume this scriptable is produced for each LOD.. so how do I get inside this at the unique game object component level? Obviouslly FLOD_Terrain[0].MeshReplacement=MyObj; won't work, so how do I basically do that?
     
  50. FimpossibleCreations

    FimpossibleCreations

    Joined:
    Jun 27, 2018
    Posts:
    348
    Right now I don't remember why 5, probably assumed noone will need more, you can modify this limit
    upload_2020-6-8_10-45-10.png

    To access this variables you can use code like this:

    Code (CSharp):
    1.        
    2.         FOptimizer_Terrain opt = GetComponent<FOptimizer_Terrain>();
    3.         FLOD_Base lod = opt.ToOptimize[0 /* Wchich optimized object - terrain optimizer have only one object */ ].LODSet.LevelOfDetailSets[0 /* Which LOD */];
    4.         FLOD_Terrain lodTerr = lod as FLOD_Terrain;
    5.         lodTerr.MeshReplacement = ...
    6.  
     
unityunity