Represents a material.
Constructors and accessors
stingray.Gui.material() stingray.Mesh.material() stingray.ShadingEnvironment.material() stingray.Terrain.material() |
Other related reference items
id ( self ) : integer
Retrieves the ID of the material.
|
self : |
Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see Object lifetimes and userdata binding, or this page in the Lua documentation. |
integer |
The ID of the material. |
set_color ( self, variable, color )
WARNING: This function is deprecated.
|
self : |
Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see Object lifetimes and userdata binding, or this page in the Lua documentation. | |
variable : | string |
The name of the color variable whose value you want to set. |
color : |
The new value to set for the variable. |
This function does not return any values. |
Use Material.set_vector3() instead, and make sure to express your color using linear color values.
set_matrix4x4 ( self, variable, value )
Sets a matrix variable in the material to the specified value.
|
self : |
Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see Object lifetimes and userdata binding, or this page in the Lua documentation. | |
variable : | string |
The name of the matrix variable whose value you want to set. |
value : |
The new value to set for the variable. |
This function does not return any values. |
set_resource ( self, slot, resource )
Sets a resource slot in the material to the specified texture resource.
|
self : |
Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see Object lifetimes and userdata binding, or this page in the Lua documentation. | |
slot : | string |
The name the texture slot which to assign a texture to. |
resource : |
The RenderResource to set. |
This function does not return any values. |
set_scalar ( self, variable, value )
Sets a scalar variable in the material to the specified value.
|
self : |
Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see Object lifetimes and userdata binding, or this page in the Lua documentation. | |
variable : | string |
The name of the scalar variable whose value you want to set. |
value : | number |
The new value to set for the variable. |
This function does not return any values. |
Other related reference items
set_shader_pass_flag ( self, flag, enabled )
Determines whether or not the specified shader pass is enabled for the material.
|
self : |
Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see Object lifetimes and userdata binding, or this page in the Lua documentation. | |
flag : | string |
The name of the shader pass flag. |
enabled : | boolean |
Use true to enable the shader pass, or false otherwise. |
This function does not return any values. |
set_texture ( self, slot, texture )
Sets a texture slot in the material to the specified texture resource.
|
self : |
Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see Object lifetimes and userdata binding, or this page in the Lua documentation. | |
slot : | string |
The name the texture slot which to assign a texture to. |
texture : | string |
The resource name of the texture to set. |
This function does not return any values. |
set_vector2 ( self, variable, vector2 )
Sets a two-dimensional vector variable in the material to the specified value.
|
self : |
Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see Object lifetimes and userdata binding, or this page in the Lua documentation. | |
variable : | string |
The name of the vector variable whose value you want to set. |
vector2 : |
The new value to set for the variable. Only the X and Y values are used. |
This function does not return any values. |
set_vector3 ( self, variable, vector3 )
Sets a three-dimensional vector variable in the material to the specified value.
|
self : |
Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see Object lifetimes and userdata binding, or this page in the Lua documentation. | |
variable : | string |
The name of the vector variable whose value you want to set. |
vector3 : |
The new value to set for the variable. |
This function does not return any values. |
To set a color value, pass the RGB values in linear color space. For example, to set the Base Color value of a material to orange:
local new_color = stingray.Vector3(1, 0.212, 0) stingray.Material.set_vector3(mat, "base_color", new_color)
If you are using a standard transparent material, and you want to set its opacity, set it as a separate scalar variable. For example, this makes the material semi-transparent orange:
local new_color = stingray.Vector3(1, 0.212, 0) local new_opacity = 0.5 stingray.Material.set_vector3(mat, "base_color", new_color) stingray.Material.set_scalar(mat, "opacity", new_opacity)
Other related reference items
set_vector4 ( self, variable, vector4 )
Sets a four-dimensional vector variable in the material to the specified value.
|
self : |
Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see Object lifetimes and userdata binding, or this page in the Lua documentation. | |
variable : | string |
The name of the vector variable whose value you want to set. |
vector4 : |
The new value to set for the variable. |
This function does not return any values. |
Note that the "standard" physically based materials provided in the core resources do not contain any Vector4 variables by default. For example, in the standard transparent material, the base_color is a Vector3 variable, and the opacity value is a separate scalar variable named opacity. You set these values through separate calls to set_vector3() and set_scalar() respectively. You should only need to call this set_vector4() function for custom materials.