Revision Difference
render.SetBlend#545975
<function name="SetBlend" parent="render" type="libraryfunc">
<description>
Sets the alpha blending for every upcoming render operation.
<bug issue="3166">This does not affect non-model render.Draw* functions.</bug>
<bug issue="3166">This does not affect non-model `render.Draw*` functions.</bug>
</description>
<realm>Client</realm>
<args>
<arg name="blending" type="number">Blending value from 0-1.</arg>
<arg name="blending" type="number">Blending value from `0-1`.</arg>
</args>
</function>
<example>
<description>Creating custom client side blending for ghosts that do not support color alpha channel</description>⤶
<description>Creating custom client side blending for ghosts that do not support color alpha channel.</description>⤶
<code>
local function BlendGhost(self)
local num = render.GetBlend()
render.SetBlend(0.8)
self:DrawModel()
render.SetBlend(num)
local num = render.GetBlend()
⤶
render.SetBlend(0.8)
self:DrawModel()
render.SetBlend(num)
end
local function MakeGhost(model, pos, ang)
local ghost = ents.CreateClientProp(model)
if(not IsValid(ghost)) then return nil end
ghost.RenderOverride = BlendGhost
ghost:SetPos(pos)
ghost:SetAngles(ang)
ghost:PhysicsDestroy()
ghost:SetNoDraw(true)
ghost:SetNotSolid(true)
ghost:DrawShadow(false)
ghost:SetSolid(SOLID_NONE)
ghost:SetMoveType(MOVETYPE_NONE)
ghost:SetCollisionGroup(COLLISION_GROUP_NONE)
ghost:SetRenderMode(RENDERMODE_TRANSALPHA)
ghost:SetColor(Color(255,255,255,255))
ghost:Spawn()
return ghost
local ghost = ents.CreateClientProp(model)
if (not IsValid(ghost)) then return end
⤶
ghost.RenderOverride = BlendGhost
ghost:SetPos(pos)
ghost:SetAngles(ang)
ghost:PhysicsDestroy()
ghost:SetNoDraw(true)
ghost:SetNotSolid(true)
ghost:DrawShadow(false)
ghost:SetSolid(SOLID_NONE)
ghost:SetMoveType(MOVETYPE_NONE)
ghost:SetCollisionGroup(COLLISION_GROUP_NONE)
ghost:SetRenderMode(RENDERMODE_TRANSALPHA)
ghost:SetColor(color_white)
ghost:Spawn()
⤶
return ghost
end
</code>
</example>