ShaderBlock

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

Constructor

new L3D.ShaderBlock()

Methods

addCode(shaderType, enabledCode, disabledCode, macros)

Register a shaderblock with the given id

Parameters
shaderType number

could be ShaderBlock.VertexShader or ShaderBlock.FragmentShader

enabledCode String

the code to insert if the shaderblock is enabled

disabledCode String

the code to insert if the shaderblock is disabled

macros Object

a set of macros to use when compiling this shader codes

getFinalCode(shaderType, blockFlags, context) → String

Returns the full code of a ShaderBlock resolving all includes, ShaderBlocks, etc.

Parameters
shaderType number

Can be ShaderBlock.VertexShader or ShaderBlock.FragmentShader

blockFlags number

A number containing the mask (every bit is a flag for a

context *

An object with variable that could be fetched by the ShaderBlocks

Returns
String