garrysmod-issues
garrysmod-issues copied to clipboard
`render.OverrideBlend(false)` doesn't disable the blending
Details
Calling render.OverrideBlend(false) doesn't fully disable / reset itself after performing certain draw operations. Comments in the reproduction code should explain it. I also included a fix I found at the bottom.
Environment
Linux on the x86-64 Chromium + 64-bit binaries branch with GModCEFCodecFix applied.
Reproduction
-- Unrelated, remove old entities just to help with testing
for _, ent in ipairs(ents.FindByClass("10C_BaseFlex")) do
ent:Remove()
end
local function create_ent(mdl)
local ent = ClientsideModel(mdl)
ent:SetPos(Vector(0, 0, 50))
ent:Spawn()
return ent
end
-- Uncomment at least one model with transparency and one model without to reproduce the issue
-- The order matters, transparent model needs to be drawn first, using `ipairs` later
local ents = {
-- Models with transparency:
create_ent("models/Kleiner.mdl"),
-- create_ent("models/props_phx/playfield.mdl"),
-- create_ent("models/maxofs2d/hover_rings.mdl"),
-- create_ent("models/maxofs2d/hover_basic.mdl"),
-- create_ent("models/props_phx/construct/windows/window_dome360.mdl"),
-- Models without transparency:
create_ent("models/props_borealis/bluebarrel001.mdl"),
-- create_ent("models/hunter/blocks/cube025x025x025.mdl"),
-- create_ent("models/props_phx/construct/metal_plate1.mdl"),
}
-- Also reproduced with `PostDrawTranslucentRenderables` and `HUDPaint` hooks, didn't bother testing more
hook.Add("PostDrawOpaqueRenderables", "", function()
render.OverrideBlend(true, BLEND_SRC_COLOR, BLEND_DST_COLOR, BLENDFUNC_MAX)
for _, ent in ipairs(ents) do
ent:DrawModel()
end
-- Uncomment the line below to fix blend not resetting / disabling correctly
-- The `srcBlend` and `destBlend` arguments don't seem to matter, but `blendFunc` needs to be set to `BLENDFUNC_ADD`
-- render.OverrideBlend(true, 0, 0, BLENDFUNC_ADD)
render.OverrideBlend(false)
end)
Screenshots
The result will be different depending on BLENDFUNC, but here are some examples:
Works fine for me, win10 chromium
Works fine for me, win10 chromium
Possible that it only affect Linux clients just like https://github.com/Facepunch/garrysmod-issues/issues/3926