Skip to main content
Version: Phaser v4.0.0-rc.6

BaseShader

A BaseShader is a small resource class that contains GLSL code for a shader.

It contains the key of the shader, the source code, and optional metadata.

The source code is not of a specific type, such as fragment or vertex,

or even an incomplete snippet of GLSL.

It's just the raw source code as a string.

It may be retrieved and compiled as you wish.

These keys can be used by Phaser.GameObjects.Shader and

Phaser.Renderer.WebGL.RenderNodes.BaseFilterShader.

BaseShaders are stored in the Shader Cache, available in a Scene via this.cache.shaders and are referenced

by a unique key-based string. Retrieve them via this.cache.shaders.get(key).

BaseShaders are created automatically by the GLSL File Loader when loading an external shader resource.

They can also be created at runtime, allowing you to use dynamically generated shader source code.

Constructor

new BaseShader(key, glsl, [metadata])

Parameters

nametypeoptionaldescription
keystringNoThe key of this shader. Must be unique within the shader cache.
glslstringNoThe GLSL source code for the shader.
metadataobjectYesAdditional metadata for this shader code.

Scope: static

Source: src/display/shader/BaseShader.js#L9
Since: 4.0.0

Public Members

glsl

glsl: string

Description:

GLSL source code for a shader.

The use of this code is not specified by Phaser.

You can add metadata to further describe its purpose.

Source: src/display/shader/BaseShader.js#L51
Since: 4.0.0


key

key: string

Description:

The key of this shader code,

unique within the shader cache of this Phaser game instance.

Source: src/display/shader/BaseShader.js#L41
Since: 3.17.0


metadata

metadata: object

Description:

Additional metadata for this shader. This is not used by Phaser,

but it may be used by your game code or external tools.

For example, you could add properties that describe

the shader's purpose, author, version, etc.

Source: src/display/shader/BaseShader.js#L62
Since: 4.0.0