Noise
A Noise Game Object.
This game object is a quad which displays random noise. You can manipulate this object like any other, make it interactive, and use it in filters and masks to create visually stunning effects.
Behind the scenes, a Noise is a Phaser.GameObjects.Shader using a specific shader program.
Noise or 'white noise' is simply random values. These are created by hashing the offset pixel coordinates, so the same noise is always created at the same position. This creates a reproducible effect.
You can set the color and transparency of the noise.
You can scroll the noise by animating the noiseOffset property. Note that floating-point precision is very important to this effect. Scrolling very large distances may cause blockiness in the output. Scrolling very small distances may cause the output to change completely, as it is not processing the same exact values. If you scroll by an exact fraction of the resolution of the object, the output will remain mostly the same, but it is not guaranteed to be stable. It's more effective to use setRenderToTexture and use this as a texture in a TileSprite.
You can set noisePower to sculpt the output levels. Higher power reduces higher values. Lower power reduces lower values.
Constructor
new Noise(scene, [config], [x], [y], [width], [height])
Parameters
| name | type | optional | default | description |
|---|---|---|---|---|
| scene | Phaser.Scene | No | The Scene to which this Game Object belongs. | |
| config | Phaser.Types.GameObjects.Noise.NoiseQuadConfig | Yes | The configuration for this Game Object. | |
| x | number | Yes | 0 | The horizontal position of this Game Object in the world. |
| y | number | Yes | 0 | The vertical position of this Game Object in the world. |
| width | number | Yes | 128 | The width of the Game Object. |
| height | number | Yes | 128 | The height of the Game Object. |
Scope: static
Extends
Source: src/gameobjects/noise/Noise.js#L12
Since: 4.0.0
Inherited Members
From Phaser.GameObjects.Components.BlendMode:
From Phaser.GameObjects.Components.ComputedSize:
From Phaser.GameObjects.Components.Depth:
From Phaser.GameObjects.Components.Filters:
- filterCamera
- filters
- filtersAutoFocus
- filtersFocusContext
- filtersForceComposite
- maxFilterSize
- renderFilters
From Phaser.GameObjects.Components.Origin:
From Phaser.GameObjects.Components.ScrollFactor:
From Phaser.GameObjects.Components.Transform:
From Phaser.GameObjects.Components.Visible:
From Phaser.GameObjects.GameObject:
- active
- body
- cameraFilter
- data
- displayList
- ignoreDestroy
- input
- isDestroyed
- name
- parentContainer
- renderFlags
- scene
- state
- tabIndex
- type
- vertexRoundMode
From Phaser.GameObjects.Shader:
- drawingContext
- glTexture
- renderNode
- renderToTexture
- texture
- textureCoordinateBottomLeft
- textureCoordinateBottomRight
- textureCoordinateTopLeft
- textureCoordinateTopRight
- textures
Public Members
noiseColorEnd
noiseColorEnd: Phaser.Display.Color
Description:
The color mapped to high noise values (approaching 1).
The default is white. You can set any color, and change the alpha.
Source: src/gameobjects/noise/Noise.js#L114
Since: 4.0.0
noiseColorStart
noiseColorStart: Phaser.Display.Color
Description:
The color mapped to low noise values (approaching 0).
The default is black. You can set any color, and change the alpha.
Source: src/gameobjects/noise/Noise.js#L103
Since: 4.0.0
noiseOffset
noiseOffset: Array.<number>
Description:
The offset of the noise in each dimension: [ x, y ]. Animate x and y to scroll the noise pattern.
This must be an array of 2 numbers.
Source: src/gameobjects/noise/Noise.js#L75
Since: 4.0.0
noisePower
noisePower: number
Description:
The power to apply to the noise value. This can enhance/suppress high/low noise.
Source: src/gameobjects/noise/Noise.js#L92
Since: 4.0.0
noiseRandomChannels
noiseRandomChannels: boolean
Description:
Whether to render channel noise separately, creating many colors of output.
Source: src/gameobjects/noise/Noise.js#L130
Since: 4.0.0
noiseRandomNormal
noiseRandomNormal: boolean
Description:
Whether to render a random normal value per pixel. The normal is in the hemisphere facing the camera.
This value overrides noiseRandomChannels.
Source: src/gameobjects/noise/Noise.js#L141
Since: 4.0.0
Inherited Methods
From Phaser.Events.EventEmitter:
- addListener
- emit
- eventNames
- listenerCount
- listeners
- off
- on
- once
- removeAllListeners
- removeListener
- shutdown
From Phaser.GameObjects.Components.BlendMode:
From Phaser.GameObjects.Components.ComputedSize:
From Phaser.GameObjects.Components.Depth:
From Phaser.GameObjects.Components.Filters:
- enableFilters
- focusFilters
- focusFiltersOnCamera
- focusFiltersOverride
- renderWebGLFilters
- setFiltersAutoFocus
- setFiltersFocusContext
- setFiltersForceComposite
- setFilterSize
- setRenderFilters
- willRenderFilters
From Phaser.GameObjects.Components.GetBounds:
- getBottomCenter
- getBottomLeft
- getBottomRight
- getBounds
- getCenter
- getLeftCenter
- getRightCenter
- getTopCenter
- getTopLeft
- getTopRight
From Phaser.GameObjects.Components.Origin:
From Phaser.GameObjects.Components.RenderSteps:
From Phaser.GameObjects.Components.ScrollFactor:
From Phaser.GameObjects.Components.Transform:
- copyPosition
- getLocalPoint
- getLocalTransformMatrix
- getParentRotation
- getWorldPoint
- getWorldTransformMatrix
- setAngle
- setPosition
- setRandomPosition
- setRotation
- setScale
- setW
- setX
- setY
- setZ
From Phaser.GameObjects.Components.Visible:
From Phaser.GameObjects.GameObject:
- addedToScene
- addToDisplayList
- addToUpdateList
- destroy
- disableInteractive
- getData
- getDisplayList
- getIndexList
- incData
- removedFromScene
- removeFromDisplayList
- removeFromUpdateList
- removeInteractive
- setActive
- setData
- setDataEnabled
- setInteractive
- setName
- setState
- setVertexRoundMode
- toggleData
- toJSON
- update
- willRender
- willRoundVertices
From Phaser.GameObjects.Shader:
- getUniform
- preDestroy
- renderImmediate
- setRenderToTexture
- setTextureCoordinates
- setTextureCoordinatesFromFrame
- setTextures
- setUniform
- setupUniforms
Public Methods
setNoiseColor
<instance> setNoiseColor([start], [end])
Description:
Set the colors of the noise, from a variety of color formats.
-
A number is expected to be a 24 or 32 bit RGB or ARGB value.
-
A string is expected to be a hex code.
-
An array of numbers is expected to be RGB or RGBA in the range 0-1.
-
A Color object can be used.
Parameters:
| name | type | optional | default | description |
|---|---|---|---|---|
| start | number | string | Array.<number> | Phaser.Display.Color | Yes |
| end | number | string | Array.<number> | Phaser.Display.Color | Yes |
Returns: Phaser.GameObjects.Noise - This game object.
Source: src/gameobjects/noise/Noise.js#L155
Since: 4.0.0