Material System

Core Systems Updated: Dec 10, 2025

Material System

Cache and manage materials efficiently.

cLib.AddMaterial

Register a material for caching.

cLib.AddMaterial(matID, path, pngParams)

Parameters:

ParameterTypeDescription
matIDstringUnique identifier
pathstringPath relative to materials/
pngParamsstringOptional PNG parameters
Example:

-- Register materials
cLib.AddMaterial("MyAddon.Logo", "myaddon/logo.png", "smooth")
cLib.AddMaterial("MyAddon.Background", "myaddon/bg.png")
cLib.AddMaterial("MyAddon.Icon", "myaddon/icon.png", "smooth mips")

cLib.GetMaterial

Retrieve a cached material (client-side only).

local mat = cLib.GetMaterial(matID)

Example:

-- Draw material
local logo = cLib.GetMaterial("MyAddon.Logo")

function PANEL:Paint(w, h)
    surface.SetDrawColor(255, 255, 255)
    surface.SetMaterial(logo)
    surface.DrawTexturedRect(10, 10, 64, 64)
end

Built-in Materials

cLib.GetMaterial("uparrow")    -- Arrow up icon
cLib.GetMaterial("downarrow")  -- Arrow down icon

PNG Parameters

ParameterDescription
smoothSmooth/bilinear filtering
mipsGenerate mipmaps
noclampDon't clamp texture
alphatestAlpha testing
Combined:

cLib.AddMaterial("icon", "path/icon.png", "smooth mips")