Class Material

Base class for materials.

A material describes the appearance of an object. This class is inherited from UniformList and provides material properties and shader management functionality.

See also:

Fields

material.default Default material instance.
material.name Material name.
material.shader The shader object that is bound to the material.
material.depth_test Depth test flag.
material.depth_func Depth comparison function used for depth testing.
material.wireframe Sets whether wireframe lines will be used when drawing.
material.mesh_cull_mode Sets whether back-facing triangles in a Mesh are culled.
material.alpha_mode Alpha blending mode for transparency.
material.main_texture The main texture to be used with mesh:setTexture().
material.shader_vertcode Vertex shader source code.
material.shader_fragcode Fragment shader source code.
material.attributes Material attributes table.

Methods

material:init ([opt]) The public constructor.


Fields

material.default
Default material instance. Pre-configured material with white base color.
  • default Material
material.name
Material name.
  • name string (default "base_material")
material.shader
The shader object that is bound to the material.
  • shader love.Shader
material.depth_test
Depth test flag.
  • depth_test boolean (default true)
material.depth_func
Depth comparison function used for depth testing. Possible values: 'never', 'less', 'equal', 'lequal', 'greater', 'notequal', 'gequal', 'always'
  • depth_func string (default "less")
material.wireframe
Sets whether wireframe lines will be used when drawing.
  • wireframe boolean (default false)
material.mesh_cull_mode
Sets whether back-facing triangles in a Mesh are culled. Possible values: 'back', 'front', 'none'
  • mesh_cull_mode string (default "back")
material.alpha_mode
Alpha blending mode for transparency. Possible values: 'OPAQUE', 'MASK', 'BLEND'
  • alpha_mode string (default "OPAQUE")
material.main_texture
The main texture to be used with mesh:setTexture(). Corresponds to uniform Image MainTex in shader.
  • main_texture love.Texture
material.shader_vertcode
Vertex shader source code.
material.shader_fragcode
Fragment shader source code.
material.attributes
Material attributes table.

Methods

material:init ([opt])
The public constructor. Creates a new menori.Material instance with optional parameters.

Parameters:

  • opt table Optional parameters table
    • name string Material name (optional)
    • shader Shader Custom shader LOVE Shader object (optional)
    • shader_vertcode string Custom vertex shader code (optional)
    • shader_fragcode string Custom fragment shader code (optional)

Usage:

    -- Create a basic material
    local material = menori.Material()
    
    -- Create a named material with custom shader
    local material = menori.Material({
        name = "MyMaterial",
        shader = my_custom_shader,
    })
    
    -- Create a named material with custom shader code
    local material = menori.Material({
        name = "MyMaterial",
        shader_vertcode = "vertex shader code here",
        shader_fragcode = "fragment shader code here",
    })
    
    -- Create a ModelNode with material
    local model_node = menori.ModelNode(mesh, material)
generated by LDoc 1.5.0 Last updated 2025-08-18 00:01:40