SetMaterial
From OxeyeWiki
video.setMaterial(materialSettings) | ||
Sets the texture material that will be used for the next set of triangles. | ||
Parameter | Expected Type | Description |
materialSettings | A table | A table containing the settings, see below. |
Returns | ||
Returns nothing. |
Table Settings
The material settings table contains the settings that should be used for the following triangles. Each setting is set by assigning its name to value in the table, for example
{ lighting = false }
means that 3d lighting should be turned off.
All settings are optional.
Setting | Description |
texture | The name of the texture (TGA or JPEG) that should be used. Default is none. |
lighting | Whether 3d lighting should be used or not. Default is true. |
zbuffer | Whether 3d z buffer should be used or not. Default is true (i.e. pixels that are behind stuff wont be rendered). |
zwrite | Whether the object should write to the z buffer. Default is true. |
materialType | The base material type. The documentation isn't finished for this setting, but 1 is solid (no transparency), 11 is "add color", 12 is "texture with alpha values" and 13 is "texture with alpha AND vertex alpha." |
clockwiseCull | Whether culling should be done clockwise or counter-clockwise. |
mirrorU | Whether textures should be mirrored along the U axis (i.e. when coordinates are outside of 0..1). |
mirrorV | Same as mirrorU, but for V coordinates. |
aa | Ambient alpha. |
ar | Ambient red. |
ag | Ambient green. |
ab | Ambient blue. |
da | Diffuse alpha. |
dr | Diffuse red. |
dg | Diffuse green. |
db | Diffuse blue. |
sa | Specular alpha. |
sr | Specular red. |
sg | Specular green. |
sb | Specular blue. |
ea | Emissive alpha. |
er | Emissive red. |
eg | Emissive green. |
eb | Emissive blue. |
shininess | Shininess (sharpness of specular). |
Notes
If you want to use materials for 2d methods, you need to call useMaterialFor2d.
Creating tables on the fly may cause memory leak problems, so it's recommended that you cache your material settings. For example,
DON'T
local function someRenderMethod() video.setMaterial({ texture = "image.jpg", lighting = false, materialType = 1 }) -- render end
but DO
local material = { texture = "image.jpg", lighting = false, materialType = 1 } local function someRenderMethod() video.setMaterial(material) -- render end