BatchShaderFactory

class 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.

Constructor


new BatchShaderFactory(vertexShaderTemplate: string, fragmentShaderTemplate: string, uniforms: UniformGroup | Map<string, object>, templateInjectors: Object<String, InjectorFunction>, disableVertexShaderTemplate: boolean) → {}

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

Parameters:
Name Type Attributes Default Description
vertexShaderTemplate string
fragmentShaderTemplate string
uniforms UniformGroup | Map<string, object>
templateInjectors Object<String, InjectorFunction>

<optional>

disableVertexShaderTemplate boolean

<optional>

true

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

Summary


Properties from BatchShaderFactory

Methods from BatchShaderFactory

(brend: BatchRenderer) => Shader
derive()

Public Properties


disableVertexShaderTemplate BatchShaderFactory.ts:87
disableVertexShaderTemplate: Boolean

Disable vertex shader templates to speed up shader generation.

Public Methods


derive BatchShaderFactory.ts:114
derive() → {(brend: BatchRenderer) => Shader}

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

Returns:
Type Description
(brend: BatchRenderer) => Shader

shader function that can be given to the batch renderer


Powered by webdoc!