✂️ Simple library for efficient and cross-platform clipping of 3D2D GUI in Garry's Mod
Left: No clipping
Right: 2D clipped
my_addon.clip = include("lib/clip.lua")
local width, height = 200, 400
cam.Start3D2D(pos, ang, scale)
my_addon.clip:Scissor2D(width, height)
-- Draw 2D clipped stuff here!
my_addon.clip()
cam.End3D2D()
local mins, maxs = ent:OBBMins(), ent:OBBMaxs()
-- or
local mins, maxs = ent:GetModelBounds()
my_addon.clip:Scissor3D(pos, ang, mins, maxs)
cam.Start3D2D(pos, ang, scale)
-- Draw 3D clipped stuff here!
cam.End3D2D()
my_addon.clip()
In most cases, this is not recommended because stencils are fundamentally 2D, leading to depth issues like this: