Scene > Shaders


Read our guide on Shaders for an explanation of these blocks.


Shaders

Apply Shader

shader-apply

Applies the specified shader to the game. This replaces the existing shader. To use multiple shaders at a time, use the combine shader blocks below.

[SHADER].enable();

Clear Shaders

shader-clear

Removes the existing shader from the game.

engine.clearShaders();

Toggle shaders for HUD layer

shader-hud

Enables/disables shaders for the HUD (top, non-scrolling) layer.

engine.toggleShadersForHUD();

Combine 2 Shaders

shader-combine

Combines 2 shaders together. If combining more than 2, stick further combines in the second slot.

[SHADER].combine([SHADER])

Combine 3 Shaders

shader-combine3

Combines 3 shaders together.

[SHADER].combine([SHADER]).combine([SHADER])

Combine 4 Shaders

shader-combine4

Combines 4 shaders together.

[SHADER].combine([SHADER]).combine([SHADER]).combine([SHADER])

Load Shader from File

shader-file

Loads a shader placed into a game's extras directory.

new ExternalShader([TEXT])

Load Shader from Text

shader-text

Define a shader inline using GLSL.

new InlineShader([TEXT])

Properties

Set Shader Property

shader-set

Instantly set a shader's properties. This lets you tweak a shader (in ways that the blocks don't allow) and alter its appearance after creation.

Consult our Shaders article for property names.

[SHADER].setProperty([TEXT], [VALUE]);

Tween a Shader Property

shader-tween

Change a shader's properties over time. Consult our Shaders article for property names.

[SHADER].tweenProperty([TEXT], [NUMBER], [NUMBER], [EASING]);

Set Time Scale for Shader

shader-time

Makes animated shaders run faster/slower. Useful for porting shaders written for other environments. 1.0 is normal time. 2.0 is twice as fast.

[SHADER].setTimeScale([NUMBER]);

Color Shaders

Hue

shader-hue

Adjusts the screen's hue in degrees.

new HueShader(0)

Contrast / Saturation / Brightness

shader-csb

Adjust the screen's contrast, saturation or brightness, in percentages. 100% means original value, 200% means twice as much, 50% means half as much.

CSBShader.create("contrast", [NUMBER]/100)
CSBShader.create("saturation", [NUMBER]/100)
CSBShader.create("brightness", [NUMBER]/100)

Tint

shader-tint

Apply a color-based tint to the screen using the specified opacity in pecentage between 0% (no tint), 100% (full tint).

new TintShader([COLOR], [NUMBER]/100)

Filter Shaders

Filters (Grayscale / Inverse / Sepia)

shader-filters

Apply simple filters (grayscale, inverse, sepia) to the screen.

new GrayscaleShader()
new InverseShader()
new SepiaShader()

Blur

shader-blur

Applies a directional blur to the screen. x/y collectively define a 'slope' for the direction, so -1,-1 is a diagonal blur.

new BlurShader([NUMBER], [NUMBER], [NUMBER])

Sharpen

shader-sharpen

Sharpen with the given intensity.

new SharpenShader([NUMBER])

Bloom

shader-bloom

Causes highlights (bright areas) to bleed and glow.

new BloomShader()

Effect Shaders

Grain

shader-grain

Apply a dynamic, film grain effect to the screen.

new GrainShader()

Scanlines

shader-scanline

Apply TV-like scanlines to the screen.

new ScanlineShader(0)