API Docs for:
Show:

LS.ShaderMaterial Class

ShaderMaterial allows to use your own shader from scratch, but you loose some of the benefits of using the dynamic shader system of LS

Constructor

LS.ShaderMaterial

(
  • object
)

Parameters:

  • object Object

    [optional] to configure from

Methods

applyToTexture

(
  • input_texture
  • output_texture
)

Takes an input texture and applies the ShaderMaterial, 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)

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
)
Boolean

Event used to inform if one resource has changed its name

Parameters:

  • resources Object

    object where all the resources are stored

Returns:

Boolean:

true if something was modified