Skip to content

mat

create

create(name: string, type: string, kv: string) -> material

Creates a new material.

Parameters

Name Type Description
name string Material name
type string Shader type
kv string Material parameters (as a KeyValue string)

Usage

local my_mat = mat.create('dank_material', 'VertexLitGeneric', 
[[
"VertexLitGeneric"
{
    "$ambientonly" 1    
}
]]);

find

find(name: string, group: string) -> material

Finds a material. If none found, returns nil.

Parameters

Name Type Description
name string Material name
group string Texture group

Usage

local my_mat = mat.find('debug/ambientcube', 'Other Textures');

for_each_material

for_each_material(callback: (mat))

Loops all existing materials.

Parameters

Name Type Description
callback function(mat: material) Item callback

Usage

mat.for_each_material(function (material)
    print(material:get_name());
end)

override_material

override_material(mat)

Overrides current material.

Warning

Calling this function outside of on_draw_model_execute forward may have undesired effect.

Parameters

Name Type Description
mat material New material

Usage

mat.override_material(my_mat);