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

Hello. For skinned meshes optimizers can switch bones quality by distance, turn off shadows, and when all meshes of animator are invisible, the animator is culled too (unless you have enabled “Always Animator” on the animator component), but animator will compute basic data for events etc.
Disabling whole game object can turn out to be not efficient, since it can trigger garbage collector and when you quickly disable/enable many game objects by visibility in camera view (like camera rotation) it can result in performance cost peaks and short fps drops.

OK thank you I’ll keep that in mind and do some testing. Also may I ask is there any point in having 3 LODs for something like the particle systems? It’s mainly just going to be on or culled right? So can I set up optimizers with just LOD0 and culled?

I mainly ask because with 3LODs nothing shows for the particle system in LOD1 and 2. So not sure if I should be expecting the asset to be doing anything to set these up or if it’s up to me to set up a lower intensive particle system in those LODs?

also did this get pushed into an update or is it something we should all be doing?

I’m working on a game that switches from walking to horseback to cars and to boats.
However, each of these have their own camera system based on the mode of travel.
Can Optimizers work with something like this or do I need to fins another solution?

Been using Optimizers for years but with just one camera object, so I am not sure how to make this work.

Thanks!

You can lower emission rate by distance but increase particles sprites size, to make it cost less but still look almost the same from the distance, but it also depends on the kind of particle.
9882210--1425660--upload_2024-6-10_11-44-4.png

In the current version gameObject.setActive switch is executed only when you enable “Deactivate Object” in the last LOD setting.

Hello, you mean you want to switch camera or display two views in the same time?
If you just want to switch camera, then use FIMSpace.FOptimizing.OptimizersManager.SetNewMainCamera().
Optimizers can handle only one active camera, it will not work with two camera views in the same time.

2 Likes

This is correct- one camera at a time, just switching cameras for the different vehicles. It is single person and multi-cams are not being used.

I’m not at my workstation right now, but where do I find “FIMSpace.FOptimizing.OptimizersManager.SetNewMainCamera()” or are you saying to add it in code or something?

I am an artist and single dev so any help will be appreciated to help me understand how to implement.

Thanks for your hard work- you make some wonderful assets!

Sorry for the delay.
Thank you.
When you’re changing main camera in code, you need to call
FIMSpace**.FOptimizing.OptimizersManager.SetNewMainCamera(myNewCamera);**
If you’re not using assembly definitions, that’s all you need to paste (just use yours “myNewCamera” reference)

Hello,
Optimizers is not changing meshes at all, it’s just switching components settings for shadow casting, motion vectors, skinning quality to skinned meshes etc. This is model made out of two meshes or these are mesh LODs? If so, are you sure that both meshes are not displayed on top of each other?

1 Like

Hey @FimpossibleCreations since culling group api can only work with once camera, will the optimizers work with my project well? I’ve multiple disabled cameras but I only have one active camera at a time, I want to know how optimizers cache the camera? In awake, start, update? Will optimizers automatically get the current active camera from the scene?
I haven’t started working with optimizers but since it clearly uses the culling group API i had this query. I’m previously using culling group api and for the camera updates, I;ve a main camera manager which returns the current active camera, so where ever a culling group required a camera paramter, I use getActiveCamera() from my main camera manager script which returns the current active camera from a list of pre cached cameras list.

Hello,
If it is one camera at a time, then it will work, but changing camera is triggering re-assigning all optimizers to new one (for scenes with a lot optimizers it can generate short lag) and it requires OptimizersManager.SetNewMainCamera call through code.

Hey Fimpoissible. Just a quick question - I’ve been using the particle system optimiser for lots of things in my scene that are ambient background related particles, like waterfalls, butterflies, fog etc. And they all work great. But I am watching the component when I am in play mode and I see that the distance check to each of these is being performed every frame for every one of the optimizers. I am starting to worry about the overhead for something like this. I have some particle systems that are part of my gameplay loop so I can directly enable / disable them with triggers rather than use the optimizer which I guess will save some performance but I am wondering what you think about this - is there any way to optimise this further? Should I even be worried about it?

Hello, you don’t need to worry. The distance value you see in the inspector window is calculated by selected component GUI code for debugging purposes, not by the component itself.
If your particles are not moving, I recommend using static optimization mode, then there is no cost of distance check.

1 Like

Thank you very much for the reply mate. Yes my stuff is marked as static and I see that you are using that fancy multiple point culling group thing that uses some intelligent combo set of points to figure out the distances right.

Hello,

Is it possible to use Optimizers for objects generated at runtime? I have many meshes for large mesh terrain that aren’t always visible, would prefer some of them culled etc.
If it’s possible, how can I do it?

Hello,

From time to time I got exceptions complaining that array index is out of bound.
It seems that I need to make a change for
FImpossible Creations\Plugins - Other\Optimizers 2\Code\Optimizers Manager\Optimizers_Manager.DynamicOptimization.cs at line 172.
change the line to:
dynamicLists[(int)optimizer.CurrentDynamicDistanceCategory].Remove(optimizer);
Because the index passed in is not really for the dynamicLists if I understand correctly?
could you check if this is indeed a issue?
Thanks!

This plugin is made to tweak LOD settings through the inspector window, so runtime approach is not official way. You can do it though.
You can try to call code like this after spawning object:

        Optimizer2 optim = newObject.AddComponent<Optimizer2>();
        optim.ToOptimize = new List<Optimizer2020LODsController>();
        optim.AssignComponentsToBeOptimizedFromAllChildren(newObject, false);
        optim.AssignComponentsToBeOptimizedFromAllChildren(newObject, true);
        optim.RefreshLODSettings();

        optim.DetectionRadius = 0.3f; // Tweak detection size for your object

Hi, when i change the DetectionRadius/DetectionBounds/DetectionOffset by Script it doesn’t seem to update in the OptimizersManager. What must I call to have the OptimizersManager reflect the change?

Edit: Actually it seems to update the DetectionOffset, but not the DetectionRadius.

Thanks.

You want to change the radius during playmode, when object was already spawned and registered by OptimizersManager? Well the plugin is made to setup detection structure during initialization, then nothing more. But you have possibility to access the structure this way:
myOptimizer.OwnerContainer.CullingSpheres[myOptimizer.ContainerSphereId].radius = …