materials
The materials namespace manages Source engine material instances and chams overrides.
Functions
Section titled โFunctionsโmaterials.find
Section titled โmaterials.findโlocal mat = materials.find(name: string) --> material_t | nilFinds an existing engine material by name (e.g. "models/player/custom_player/...").
materials.create
Section titled โmaterials.createโlocal mat = materials.create(name: string, shader: string, keyvalues: table) --> material_tDynamically compiles a new material.
shader: Engine shader name (e.g."VertexLitGeneric","UnlitGeneric").keyvalues: Table of shader parameters. Key names are written without the leading$prefix (e.g.basetexture,ignorez,nofog,envmap).- String and number values are forwarded; boolean/nested tables are omitted.
local glow_mat = materials.create("script/glow", "VertexLitGeneric", { basetexture = "vgui/white", ignorez = 1, envmap = "models/effects/cube_white", envmaptint = "[1 1 1]", envmapfresnel = 1,})materials.draw_chams
Section titled โmaterials.draw_chamsโmaterials.draw_chams(mat: material_t)Draws the model currently being intercepted inside a draw_chams callback.
material_t Methods
Section titled โmaterial_t Methodsโ| Method | Parameters | Returns | Description |
|---|---|---|---|
mat:get_name |
(none) | string |
Material name. |
mat:color_modulate |
clr?: color |
color |
Reads or sets RGB color modulation tint. |
mat:alpha_modulate |
alpha?: number |
number |
Reads or sets alpha modulation (0..1). |
mat:var_flag |
flag: number, value?: boolean |
boolean |
Reads or writes a material variable flag (e.g. ignorez = 1 << 15). |
mat:increment_ref_count |
(none) | nil |
Increments reference count to prevent garbage collection across map changes. |
mat:decrement_ref_count |
(none) | nil |
Decrements reference count on cleanup. |
