A developer guide for the Sunset Synthwave material in the Game Systems/Shaders and Post Processors folder. This shader is provided
as a WebGL 2.0 fragment shader string for use with Excalibur.js materials.
Sunset Synthwave renders a procedural synthwave sunset scene with volumetric haze, stars, reflective surfaces, and optional
audio-reactive modulation. It is best used as a fullscreen background actor or post-process material in an Excalibur.js game.
sunsetShader.ts— exports the shader source asshaderBackgroundActor.ts— shows how to create the material, attach it to an actor, and update uniforms per framess.gif— visual reference for the shader effect
import { shader } from "./sunsetShader";
import { Background } from "./BackgroundActor";const game = new Engine({
width: 1500, // the width of the canvas
height: 800, // the height of the canvas
displayMode: DisplayMode.Fixed, // the display mode
pixelArt: true,
backgroundColor: Color.Black, // <---- this makes colors look mo better
});
await game.start();const background = new Background(game); // Example background actor provided in repo
game.add(background);:::note Review the Background Actor for implementation details :::
The shader uses these uniforms:
iTime— elapsed time in secondsiTimeDelta— frame delta time in secondsiResolution— current screen resolution asvec2iChannelResolution— float array for channel resolutionsiChannel0— optional texture sampler for audio or external input
iChannel0 is optional and currently disabled by default using #define disable_sound_texture_sampling. To enable audio or
texture-driven modulation:
- remove or comment out
#define disable_sound_texture_sampling - provide
iChannel0as a sampler2D - set
iChannelResolution[0]to the channel texture resolution
The shader file contains several compile-time defines that alter the effect:
AA— anti-aliasing sample countVAPORWAVE— alternate pastel tint modestereo— stereo offset for cross-eyed/parallax renderingwave_thing— toggles animated wave distortioncity— enables stylized city silhouette detail
Example config changes:
#define AA 4
#define VAPORWAVE
//#define stereo 1.
//#define city- Use this shader for fullscreen backgrounds or post-process passes rather than small sprites.
- Keep
iResolutionsynchronized with the render surface dimensions. - If you add
iChannel0, ensure the texture is valid andiChannelResolutionis set correctly. - Use
engine.clock.now() / 1000for consistent time-based animation.
BackgroundActor.ts demonstrates:
- creating the material
- assigning it to an actor
- updating shader uniforms every frame
- preparing channel resolution data for optional input
This shader is part of the Game Dev Library and follows the repository licensing terms.
Inspired by synthwave and sunset shader styles, adapted for Excalibur.js with procedural rendering techniques. '@ Set-Content -Path 'c:\programming\Game Dev Library\Game Systems\Shaders and Post Processors\Sunset Synthwave\readme.md' -Value $content -Encoding utf8
