API Docs for:
Show:

LS.ShaderBlock Class

Defined in: ../src/shaders.js:234
Module: LS

A ShaderBlock represents a block of GLSL code that could be requested by a shader in order to obtain a functionality. SBs are registered and given a number, then if a shader wants that functionality it could use #pragma shaderblock "sb_name" it will be inserted in the material in the line of the pragma

Constructor

LS.ShaderBlock

()

Item Index

Methods

addCode

(
  • shader_type
  • enabled_code
  • disabled_code
  • macros
)

register a shaderblock with the given id shader_type: vertex or fragment shader

Parameters:

  • shader_type Enum

    could be GL.VERTEX_SHADER or GL.FRAGMENT_SHADER

  • enabled_code String

    the code to insert if the shaderblock is enabled

  • disabled_code String

    the code to insert if the shaderblock is disabled

  • macros Object

    [optional] a set of macros to use when compiling this shader codes

getFinalCode

(
  • shader_type
  • block_flags
  • context
)
String

Returns the full code of a shaderblock resolving all includes, shaderblocks, etc shadertype: GL.VERTEX_SHADER = 35633, GL.FRAGMENT_SHADER = 35632

Parameters:

  • shader_type Enum

    could be GL.VERTEX_SHADER or GL.FRAGMENT_SHADER

  • block_flags Number

    a number containing the mask (every bit is a flag for a shaderblock) with all the enabled shader blocks

  • context String

    an object with variable that could be fetched by the shaderblocks

Returns:

String:

the final code ready to be compiled

register

()

Registers this shaderblock in the global LS.Shaders container