Performance issues with Halo

Hi, halo.Add() is the alternative to Entity:DrawEntityOutline().
I am developing a Farming gamemode and I wanted to do the next thing:
Whenever a crop is ready to collect, draw an outline to notice the player that it’s ready to collect, but I’m having a lot of perfomance issues because of the outline (halo). Also, I added the halo feature to the crop_plot you’re looking at (working like a crosshair, more or less…)
I’ll show you everything with screenshots taken in-game:

As you can see I get about 193FPS, without any halo drawing at these moment

When I stare at a single one I get 106FPS (87FPS LESS!!!)
The code for that halo is:

        local looking_at = {}	
        local ply_eye_trace = LocalPlayer():GetEyeTrace().Entity
	if ply_eye_trace:GetClass() == "crop_plot" and ply_eye_trace:GetPos():Distance(LocalPlayer():GetPos()) < 80 then
		table.insert(looking_at, ply_eye_trace)
		local glow_var =  math.abs(math.sin(CurTime() * 2))
		halo.Add(looking_at, Color(0 ,glow_var*145 + 110, 0), 10, 10, 2, true, true)

PD: I know that I’ve set re-render 10 times but anyway, when it’s low stills creating performance issues.

This one is when the crop plot is ready to collect with 113FPS (80FPS LESS!!!) (I am not aiming at that crop plot)
The code for that halo is the next one:

	local looking_at = {}
--This detects and adds automatically the crops ready to collect--
	for k, v in pairs(ents.GetAll()) do
		if v:GetClass() == "crop_plot" and v:GetNWBool("ready_to_collect") == true then
			table.insert(ready_to_collect, v)
--if the table is not empty then it runs the halo function-- 

	if table.Count(ready_to_collect) != 0 then
		halo.Add(ready_to_collect, Color(0, 255, 0), 0, 0, 2, true, true)

Staring at an empty crop plot and crop ready to collect 94FPS (99FPS LESS)

I’ve to add that all halo functions are inside a hook “PreDrawHalos”. I’m looking forward to someone helps me giving me an alternative or a solution to these performance issues. THANKS!
PD: I’m sorry if the pictures are too big, I do not know how to resize them in the forum.
PDD: If you need more info tell me, I’ll be pleased to tell you.

You really just shouldn’t use halos if you care about optimization, you could just set the color of the entity with a low alpha then set it back? I know its not as great, but it will not cause performance issues!

I do not really care, but the fact that about almost a 50% of my total fps are down because of halos makes me worry about it.
Your idea is good, but I don’t like it that much… Thank you anyway for answering!!! :wink:

Have you tried changing that 2 at the end of halo.Add to 1? It sets the number of passes on the effect and it might give you better performance.

Sure! But it doesn’t change that much… It only improved my fps by 5~10… Do you have any other suggestion instead of halo? Btw, could you try it on your pc? Maybe there’s just something wrong with me…
Thank you for answering!

No its just not you. Calling halo is a very expensive function when talking about framerates.
You should instead try something else like for example this:

[editline]11th September 2016[/editline]

Its just an alternative, but its not better than halos.

Thank you so much! It looks kinda cool, anyway I’ll try it later.
By the way, the physgun uses halos right? what if I use the halo that physgun uses? I’ll try that too later.

Thank you everybody for helping me out.

Yes I am having the same problem. You can test this also on Sandbox when you use the physgun to pick up an object. You will feel the fps drop. With halo. But this drops less fps than Halo.

It’s true, I have never noticed before. It goes from 120FPS to 70FPS WOW (50FPS less). Will this be fixed? or there’s just no solution for it? or maybe do we need NASA computers?
Thank you again.

No it just need a fix. Maybe render problem.