API Docs for:
Show:

LS.UnityMaterial Class

UnityMaterial allows to use Unity ShaderLab materials

Constructor

LS.UnityMaterial

(
  • object
)

Parameters:

  • object Object

    [optional] to configure from

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_texture Texture
  • output_texture Texture

    [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:

  • name String

    the property name as it should be shown

  • value

    the default value

  • type String

    the data type (use LS.TYPES)

  • options Object

    an 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:

  • name String

    the property name as it should be shown

  • uniform String

    the uniform name in the shader

  • options Object

    an object containing all the possible options (used mostly for widgets)

  • value String

    default 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:

  • name String

    the property name as it should be shown

  • uniform String

    the uniform name in the shader

  • type String

    the var type in case we want to edit it (use LS.TYPES)

  • value
  • options Object

    an object containing all the possible options (used mostly for widgets)

getPropertiesInfo

() Object

gets all the properties and its types

Returns:

Object:

object with name:type

getProperty

() Object

gets all the properties and its types

Returns:

Object:

object with name:type

getResources

(
  • resources
)
Texture

Collects all the resources needed by this material (textures)

Parameters:

  • resources Object

    object where all the resources are stored

Returns:

Texture:

getResources

(
  • resources
)
Texture

Collects all the resources needed by this material (textures)

Parameters:

  • resources Object

    object where all the resources are stored

Returns:

Texture:

onResourceRenamed

(
  • resources
)
Texture

Event used to inform if one resource has changed its name

Parameters:

  • resources Object

    object where all the resources are stored

Returns:

Texture:

setProperty

(
  • object
)

assign a value to a property in a safe way

Parameters:

  • object Object

    to configure from

setTexture

(
  • channel
  • texture
)

Assigns a texture to a channel

Parameters:

  • channel String
  • texture Texture