Garry's Mod Wiki

halo.Add

  halo.Add( table entities, table color, number blurX = 2, number blurY = 2, number passes = 1, boolean additive = true, boolean ignoreZ = false )

Description

Applies a halo glow effect to one or multiple entities.

Using this function outside of the GM:PreDrawHalos hook can cause instability or crashes.
The ignoreZ parameter will cause the halos to draw over the player's viewmodel. You can work around this using render.DepthRange in the GM:PreDrawViewModel, GM:PostDrawViewModel, GM:PreDrawPlayerHands and GM:PostDrawPlayerHands hooks.

Arguments

1 table entities
A table of entities to add the halo effect to.
2 table color
The desired color of the halo. See Color.
3 number blurX = 2
The strength of the halo's blur on the x axis.
4 number blurY = 2
The strength of the halo's blur on the y axis.
5 number passes = 1
The number of times the halo should be drawn per frame. Increasing this may hinder player FPS.
6 boolean additive = true
Sets the render mode of the halo to additive.
7 boolean ignoreZ = false
Renders the halo through anything when set to true.

Example

Adds a halo around all props in the map using an O(n) operation and iterating through unseen objects which can be extremely expensive to process.

local color_red = Color( 255, 0, 0 ) hook.Add( "PreDrawHalos", "AddPropHalos", function() halo.Add( ents.FindByClass( "prop_physics*" ), color_red, 5, 5, 2 ) end )
Output: All the props on the map will be rendered with a red halo, a blur amount of 5, and two passes.

Example

Adds a green halo around all admins.

local color_green = Color( 0, 255, 0 ) hook.Add( "PreDrawHalos", "AddStaffHalos", function() local staff = {} for _, ply in ipairs( player.GetAll() ) do if ( ply:IsAdmin() ) then staff[ #staff + 1 ] = ply end end halo.Add( staff, color_green, 0, 0, 2, true, true ) end )