natiny.material.set_vertex_constant

Lua
natiny.material.set_vertex_constant(material, name, constant_type)

Declares that the engine owns a constant: before every draw it is refilled with an engine-provided value instead of keeping whatever you set.

Members named mtx_world, mtx_view, mtx_proj, mtx_worldview, mtx_viewproj, mtx_worldviewproj and mtx_normal are declared this way for you. Use this call when your shader names them differently, or to turn one back into a plain user constant.

Parameters

Name Type Description
material number Material handle
name string Member name inside one of the shader's uniform blocks
constant_type number One of the constants below

Constant types

Constant Meaning
natiny.material.USER whatever you set
natiny.material.WORLD the drawn object's world transform
natiny.material.VIEW camera view
natiny.material.PROJECTION projection
natiny.material.WORLDVIEW view × world
natiny.material.VIEWPROJ projection × view
natiny.material.WORLDVIEWPROJ projection × view × world
natiny.material.NORMAL inverse transpose of worldview
natiny.material.INV_VIEW inverse of the camera view
natiny.material.INV_PROJECTION inverse projection
natiny.material.INV_VIEWPROJ inverse of projection × view
natiny.material.CAMERA_POS vec4: the eye in world space
natiny.material.TARGET_SIZE vec4: width, height, 1/width, 1/height

Example

Lua
natiny.material.set_vertex_constant(material, "u_mvp", natiny.material.WORLDVIEWPROJ)