natiny.material.set_state
Lua
natiny.material.set_state(material, { blend = ..., cull = ..., depth = ... })
Sets the material's blend, face-culling and depth-test state. Omitted fields
are reset to their defaults.
Parameters
| Name |
Type |
Description |
material |
number |
Material handle |
state |
table |
Any of blend, cull, depth |
Blend
| Constant |
Meaning |
natiny.material.BLEND_ALPHA |
straight alpha - the default |
natiny.material.BLEND_NONE |
overwrite |
natiny.material.BLEND_ADD |
additive blending |
Cull
| Constant |
Meaning |
natiny.material.CULL_DEFAULT |
2D keeps both faces, 3D drops the back |
natiny.material.CULL_NONE |
keep both |
natiny.material.CULL_BACK |
drop back faces |
natiny.material.CULL_FRONT |
drop front faces |
Depth
| Constant |
Meaning |
natiny.material.DEPTH_DEFAULT |
2D draws ignore depth, 3D draws use it |
natiny.material.DEPTH_OFF |
no test, no write |
natiny.material.DEPTH_ON |
test and write |
natiny.material.DEPTH_TEST |
test, but leave the buffer alone |
Example
Lua
natiny.material.set_state(material, {
blend = natiny.material.BLEND_NONE,
depth = natiny.material.DEPTH_OFF,
})
Notes
- A newly created material uses
BLEND_ALPHA, CULL_DEFAULT and
DEPTH_DEFAULT.
- Changing the state invalidates the material's pipelines; they are rebuilt on
the next draw. Reapplying the same state is a no-op.
- One blend mode applies to every target written by the shader.