LS.UnityMaterial Class
UnityMaterial allows to use Unity ShaderLab materials
Constructor
LS.UnityMaterial
-
object
Parameters:
-
objectObject[optional] to configure from
Item Index
Methods
applyToTexture
-
input_texture -
output_texture
Takes an input texture and applies the UnityMaterial, the result is shown on the viewport or stored in the output_texture The ShaderCode must contain a "fx" method. Similar to the method BlitTexture in Unity
Parameters:
-
input_textureTexture -
output_textureTexture[optional] where to store the result, if omitted it will be shown in the viewport
createProperty
-
name -
value -
type -
options
Creates a property for this material, this property wont be passed to the shader but can be used from source code. You must used this function if you want the data to be stored when serializing or changing the ShaderCode
Parameters:
-
nameStringthe property name as it should be shown
-
valuethe default value
-
typeStringthe data type (use LS.TYPES)
-
optionsObjectan object containing all the possible options (used mostly for widgets)
createSampler
-
name -
uniform -
options -
value
Similar to createUniform but for textures, it helps specifying sampler options
Parameters:
-
nameStringthe property name as it should be shown
-
uniformStringthe uniform name in the shader
-
optionsObjectan object containing all the possible options (used mostly for widgets)
-
valueStringdefault value (texture name)
createUniform
-
name -
uniform -
type -
value -
options
Makes one shader variable (uniform) public so it can be assigned from the engine (or edited from the editor)
Parameters:
-
nameStringthe property name as it should be shown
-
uniformStringthe uniform name in the shader
-
typeStringthe var type in case we want to edit it (use LS.TYPES)
-
value -
optionsObjectan object containing all the possible options (used mostly for widgets)
getPropertiesInfo
()
Object
gets all the properties and its types
Returns:
object with name:type
getProperty
()
Object
gets all the properties and its types
Returns:
object with name:type
getResources
-
resources
Collects all the resources needed by this material (textures)
Parameters:
-
resourcesObjectobject where all the resources are stored
Returns:
getResources
-
resources
Collects all the resources needed by this material (textures)
Parameters:
-
resourcesObjectobject where all the resources are stored
Returns:
onResourceRenamed
-
resources
Event used to inform if one resource has changed its name
Parameters:
-
resourcesObjectobject where all the resources are stored
Returns:
setProperty
-
object
assign a value to a property in a safe way
Parameters:
-
objectObjectto configure from
setTexture
-
channel -
texture
Assigns a texture to a channel
Parameters:
-
channelString -
textureTexture
