Class: BatchShaderFactory

.brend~BatchShaderFactory

Exposes an easy-to-use API for generating shader-functions to use in the batch renderer!

You are required to provide an injector map, which maps macros to functions that return a string value for those macros given a renderer. By default, only one injector is used - the textures per batch %texturesPerBatch% macro. This is replaced by the number of textures passed to the uSamplers textures uniform.

Built-in Injectors:

  • %texturesPerBatch%: replaced by the max. textures allowed by WebGL context

  • %uniformsPerBatch%: replaced by the (aggregate-uniforms) batch factory's MAX_UNIFORMS property.

new BatchShaderFactory (vertexShaderTemplate, fragmentShaderTemplate, uniforms, templateInjectors, disableVertexShaderTemplate)

WARNING: Do not pass uSamplers in your uniforms. They will be added to your shader instance directly.

Name Type Default Description
vertexShaderTemplate string
fragmentShaderTemplate string
uniforms UniformGroup | Map.<string, object>
templateInjectors Object.<String, PIXI.brend.InjectorFunction> optional
disableVertexShaderTemplate boolean true optional

turn off (true) if you aren't using macros in the vertex shader

Members

disableVertexShaderTemplate Boolean

Disable vertex shader templates to speed up shader generation.

Methods

This essentially returns a function for generating the shader for a batch renderer.

Returns:
shader function that can be given to the batch renderer