Phaser API Documentation

  Version: 
Filter
This is a beta release of our new docs system. Found an issue?
Please tell us about it in the #📖-newdocs-feedback channel on the Phaser Discord

Phaser . Display . BaseShader

This is a beta release of our new docs system. Found an issue?
Please tell us about it in the #📖-newdocs-feedback channel on the Phaser Discord

Phaser . Display . BaseShader

A BaseShader is a small resource class that contains the data required for a WebGL Shader to be created.

It contains the raw source code to the fragment and vertex shader, as well as an object that defines the uniforms the shader requires, if any.

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.

Default fragment and vertex source is used if not provided in the constructor, setting-up a basic shader, suitable for debug rendering.

Constructor:

new BaseShader(key, [fragmentSrc], [vertexSrc], [uniforms])

Parameters:

name type arguments description
key string

The key of this shader. Must be unique within the shader cache.

fragmentSrc string <optional>

The fragment source for the shader.

vertexSrc string <optional>

The vertex source for the shader.

uniforms any <optional>

Optional object defining the uniforms the shader uses.

Since: 3.17.0

Members

fragmentSrc: string
Focus
Focus

Description:

The source code, as a string, of the fragment shader being used.

Type:
string
Since: 3.17.0
Focus
Focus
key: string
Focus
Focus

Description:

The key of this shader, unique within the shader cache of this Phaser game instance.

Type:
string
Since: 3.17.0
Focus
Focus
<nullable> uniforms: any
Focus
Focus

Description:

The default uniforms for this shader.

Type:
any
Since: 3.17.0
Focus
Focus
vertexSrc: string
Focus
Focus

Description:

The source code, as a string, of the vertex shader being used.

Type:
string
Since: 3.17.0
Focus
Focus