Material - stingray.Material object reference - Stingray Lua API Reference

stingray.Material object reference

Description

Represents a material.

Functions

Parameters

self :

stingray.Material

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.
Returns

integer

The ID of the material.

Parameters

self :

stingray.Material

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 :

stingray.Quaternion

The new value to set for the variable.

Returns
This function does not return any values.

Use Material.set_vector3() instead, and make sure to express your color using linear color values.

Parameters

self :

stingray.Material

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 :

stingray.Matrix4x4

The new value to set for the variable.

Returns
This function does not return any values.
Parameters

self :

stingray.Material

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 :

stingray.RenderResource

The RenderResource to set.

Returns
This function does not return any values.
Parameters

self :

stingray.Material

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.

Returns
This function does not return any values.
Parameters

self :

stingray.Material

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.

Returns
This function does not return any values.
Parameters

self :

stingray.Material

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.

Returns
This function does not return any values.
Parameters

self :

stingray.Material

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 :

stingray.Vector3

The new value to set for the variable. Only the X and Y values are used.

Returns
This function does not return any values.
Parameters

self :

stingray.Material

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 :

stingray.Vector3

The new value to set for the variable.

Returns
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)
Parameters

self :

stingray.Material

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 :

stingray.Quaternion

The new value to set for the variable.

Returns
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.