Closed eobet closed 4 years ago
Just a quick thing that might help but in the OnPreRender() method there are several GetComponent<> calls that can be cleared up. That will also reduce the GC Allocs from ~4.6KB to 0.8KB, I haven't spent a lot of time investigating the other Allocs because I will only ever have one OutlineEffect on at a time.
There's a PR to clean up the GetComponent problem but I still have some gc allocation.
There is a UpdateOutlineCameraFromSource
call on every OnPreRender
which has a outlineCamera.CopyFrom(sourceCamera);
as well as creates a new color/rect every frame, this could be leaky too. I don't think that call is important every frame (if you change your mainCamera settings you could call it again on the frame its needed).
I have forked this project with the goal of improving performance. One of the optimizations I have made is that OutlineEffect.OnPreRender() returns immediately if there are no active outlines.
Would love some feedback. I promise to look at any pull requests in a timely manner. https://github.com/JimmyCushnie/Outline-Effect-but-its-faster
Fixed with #43 .
Looking at the Profiler, even with all Outline components disabled (which required the integration of the Pull request currently open), OutlineEffect.OnPreRender() consumes 0.3ms of render time.
(With a few outlines enabled, we're up to 1ms which is quite expensive, but also a separate issue.)