cakeslice / Outline-Effect

Outline Image Effect for Unity
MIT License
1.43k stars 198 forks source link

Even with all outlines disabled, effect consumed 0.3ms #36

Closed eobet closed 4 years ago

eobet commented 6 years ago

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.)

SirManGuy commented 6 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.

MrGadget1024 commented 5 years ago

There's a PR to clean up the GetComponent problem but I still have some gc allocation.

f0ff886f commented 5 years ago

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).

JimmyCushnie commented 5 years ago

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. 0ms

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

JimmyCushnie commented 4 years ago

Fixed with #43 .