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

Types.GameObjects.Shader

ShaderConfig

<static> ShaderConfig

nametypeoptionaldefaultdescription
configstring | Phaser.Types.GameObjects.Shader.ShaderQuadConfigNoThe configuration object this Shader will use. It can also be a key that corresponds to a shader in the shader cache, which will be used as fragmentKey in a new config object.
widthnumberYes128The width of the Game Object.
heightnumberYes128The height of the Game Object.

Type: object

Member of: Phaser.Types.GameObjects.Shader

Source: src/gameobjects/shader/typedefs/ShaderConfig.js#L1
Since: 3.50.0


ShaderQuadConfig

<static> ShaderQuadConfig

nametypeoptionaldescription
namestringNoThe name of the render node. This is also used for shaderName if not set.
shaderNamestringYesThe name of the shader. This is used as the stub for the internal shader name. If another shader with the same name exists, that will be used instead, so it's best to use a unique name.
fragmentSourcestringYesThe fragment shader source code. This overrides anything set in fragmentKey.
vertexSourcestringYesThe vertex shader source code. This overrides anything set in vertexKey.
fragmentKeystringYesThe key of the fragment shader source to use from the shader cache.
vertexKeystringYesThe key of the vertex shader source to use from the shader cache.
setupUniformsfunctionYesA function that sets any uniform values that the shader needs. It takes two parameters: setUniform and drawingContext. setUniform is a function (name: string, value: any) => void that you can call to set a uniform value. drawingContext is the current drawing context.
initialUniformsobjectYesAn object containing the initial uniform values to set. The keys are the uniform names, and the values are the uniform values. This is used to set up the shader before it is rendered for the first time.
shaderAdditionsArray.<Phaser.Types.Renderer.WebGL.ShaderAdditionConfig>YesAdditional snippets to add to the shader. An advanced configuration option. You can use updateShaderConfig to edit these at render time, resulting in different shaders.
updateShaderConfigfunctionYesA function that updates the shader configuration. An advanced configuration option. It takes three parameters: drawingContext, gameObject, renderNode. drawingContext is the current drawing context. gameObject is the object which is rendering. renderNode is the ShaderQuad render node which invoked the function.

Type: object

Member of: Phaser.Types.GameObjects.Shader

Source: src/gameobjects/shader/typedefs/ShaderQuadConfig.js#L1
Since: 4.0.0