local depthmin
= 1.0
local spawn_copies
= {}
local custom_white_color
= Color(
255,
255,
255,
92 )
hook.
Add(
"PreDrawOpaqueRenderables",
"advanced_effect",
function( bDrawingDepth, bDrawingSkybox )
render.
DepthRange( depthmin,
1.0 )
if ( !spawn_copies )
then return false end
if ( depthmin
> 0.0 )
then
depthmin
= depthmin
- 0.001
else
local alpha
= 0
local valid_copies
= 0
for _, spawncopy
in ipairs(spawn_copies)
do
if (
IsValid( spawncopy ) )
then
alpha
= spawncopy:
GetColor().a
if ( alpha
> 0 )
then
spawncopy:
SetColor(
Color(
255,
255,
255, alpha
- 1 ) )
else
spawncopy:
Remove()
end
valid_copies
= valid_copies
+ 1
end
end
if ( valid_copies
== 0 )
then
spawn_copies
= nil
end
end
end )
hook.
Add(
"OnEntityCreated",
"advanced_effect",
function( ent )
if ( !spawn_copies )
then return end
if (
ent:
GetClass()
~= "class C_BaseFlex" and
ent:
GetRenderGroup()
== RENDERGROUP_OPAQUE
and
ent:
GetClass()
~= "gmod_hands" )
then
local mdl
= ent:
GetModel()
if (
string.
EndsWith( mdl,
".mdl" ) )
then
local spawncopy
= ClientsideModel( mdl )
spawncopy:
SetMaterial(
"models/overlay_rendertarget" )
spawncopy:
AddEffects( EF_BONEMERGE )
spawncopy:
SetParent( ent )
spawncopy:
SetRenderMode( RENDERMODE_TRANSALPHA )
spawncopy:
SetColor( custom_white_color )
table.
insert( spawn_copies, spawncopy )
end
end
end )