Phaser.GameObjects.Components.Lighting
Scope: static
Source: src/gameobjects/components/Lighting.js#L7
Since: 4.0.0
Static functions
lighting
lighting: boolean
Description:
Controls whether this Game Object participates in the WebGL lighting system. When true, the object will respond to dynamic lights added via the Lights plugin, using normal maps to calculate per-pixel diffuse lighting.
This flag is used to select the appropriate WebGL shader at render time.
Tags:
- webglOnly
Source: src/gameobjects/components/Lighting.js#L24
Since: 4.0.0
selfShadow
selfShadow: Object
Description:
Configuration object controlling self-shadowing for this Game Object. Self-shadowing causes surfaces to cast contact shadows on themselves based on the normal map, giving the appearance of depth. It is only active when lighting is also enabled.
If enabled is null, the value from the game config option render.selfShadow is used instead.
This object is used to select and configure the appropriate WebGL shader at render time.
Tags:
- webglOnly
Source: src/gameobjects/components/Lighting.js#L40
Since: 4.0.0
Static functions
setLighting
<instance> setLighting(enable)
Description:
Enables or disables WebGL-based per-pixel lighting for this Game Object. When enabled, the object will respond to dynamic lights added to the scene via the Lights plugin, using a normal map for lighting calculations. Disabling lighting restores the standard unlit rendering path.
Tags:
- webglOnly
Parameters:
| name | type | optional | description |
|---|---|---|---|
| enable | boolean | No | true to use lighting, or false to disable it. |
Returns: Phaser.GameObjects.Components.Lighting - This GameObject instance.
Source: src/gameobjects/components/Lighting.js#L62
Since: 4.0.0
setSelfShadow
<instance> setSelfShadow([enabled], [penumbra], [diffuseFlatThreshold])
Description:
Configures the self-shadowing properties of this Game Object. Self-shadowing uses the normal map to cast contact shadows on the surface itself, giving the impression of depth and raised detail. It is only active when lighting is also enabled on this Game Object.
Parameters that are undefined are left unchanged, allowing partial updates.
Tags:
- webglOnly
Parameters:
| name | type | optional | description |
|---|---|---|---|
| enabled | boolean | Yes | true to use self-shadowing, false to disable it, null to use the game default from config.render.selfShadow, or undefined to keep the setting. |
| penumbra | number | Yes | The penumbra value for the shadow. Lower is sharper but more jagged. Default is 0.5. |
| diffuseFlatThreshold | number | Yes | The texture brightness threshold at which the diffuse lighting will be considered flat. Range is 0-1. Default is 1/3. |
Returns: Phaser.GameObjects.Components.Lighting - This GameObject instance.
Source: src/gameobjects/components/Lighting.js#L81
Since: 4.0.0