materials

Material system

create

materials.create(name: string, type: string, shader_params: table) Material

Creates new material from specified shader parameters.

Example
local metallic = materials.create("metallic_chams", "VertexLitGeneric", {
    basetexture = "vgui/white_additive",
    ignorez = 0,
    envmap = "env_cubemap",
    normalmapalphaenvmapmask = "1",
    envmapcontrast = "1",
    nofog = "1",
    model = "1",
    nocull = "0",
    selfillum = "1",
    halflambert = "1",
    znearer = "0",
    flat = "1" 
})

find

materials.find(name: string) Material

draw_model

materials.draw_model(material: Material[, alpha: number])

Renders model with specified material. Can only be called inside draw_chams callback.

Material

get_name

mat:get_name() string

color_modulate

mat:color_modulate([col: color]) color

Returns color modulation if col is nil, otherwise sets new color modulation.

alpha_modulate

mat:alpha_modulate([alpha: number]) number

Returns alpha modulation if alpha is nil, otherwise sets new alpha modulation, for rendering transparent models prefer using alpha parameter in draw_model function.

var_flag

mat:var_flag(flag: number[, on: boolean]) boolean

increment_ref_count

mat:increment_ref_count()

decrement_ref_count

mat:decrement_ref_count()

Last updated