natiny.material.create

Lua
natiny.material.create(shader [, tags]) -> material

Builds a material from a shader's reflected constants, textures and vertex layout. Render pipelines are created lazily for the render states and target layouts used when drawing.

Parameters

Name Type Default Description
shader number Shader handle from natiny.shader.load
tags string or table nil Tag name or list of tag names

Returns

Type Description
number Material handle; raises an error if creation fails

Example

Lua
local material = natiny.material.create(shader, "world")

Notes

  • Creation fails for an invalid shader, unsupported vertex attributes, uniform blocks beyond the backend limit, layout errors, or too many fragment outputs.
  • The material retains a dependency on the shader. Destroy all materials made from a shader before destroying that shader.
  • Tags are used by natiny.render.tag. A material without tags is still usable through natiny.material.bind.