Scenes > Shaders


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


Shaders

Apply Shader

apply shader to game

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

clear shaders from game

Removes the existing shader from the game.

engine.clearShaders();

Toggle shaders for HUD layer

toggle shaders for hud layer

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

engine.toggleShadersForHUD();

Combine 2 Shaders

shader + shader

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

[SHADER].combine([SHADER])

Combine 3 Shaders

shader + shader + shader

Combines 3 shaders together.

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

Combine 4 Shaders

shader + shader + shader + shader

Combines 4 shaders together.

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

Load Shader from File

shader from file text

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

new ExternalShader([TEXT])

Load Shader from Text

shader from code text

Define a shader inline using GLSL.

new InlineShader([TEXT])

Properties

Set Shader Property

set text for shader to object

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

change text for shader to number over number sec using dropdown

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

set time scale to number for shader

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

adjust hue by number degrees

Adjusts the screen's hue in degrees.

new HueShader([NUMBER])

Contrast / Saturation / Brightness

set contrast to number %

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

tint using color at number %

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)

grayscale filter

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

new GrayscaleShader()
new InvertShader()
new SepiaShader()

Blur

blur by x number y number , number pixels

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

sharpen by number

Sharpen with the given intensity.

new SharpenShader([NUMBER])

Bloom

bloom filter

Causes highlights (bright areas) to bleed and glow.

new BloomShader()

Effect Shaders

Grain

add grain

Apply a dynamic, film grain effect to the screen.

new GrainShader()

Scanlines

add scanlines with width number px

Apply TV-like scanlines to the screen.

new ScanlineShader([NUMBER])