A lightweight CRT post-processing effect for Phaser 3 as a Scene Plugin. WebGL-only; safely no-ops on Canvas. You can see the plugin in action in the game Exovore.
npm install phaser-plugin-crtImport and register as a Scene Plugin:
import Phaser from "phaser";
import { CRTPlugin } from "phaser-plugin-crt";
const config: Phaser.Types.Core.GameConfig = {
type: Phaser.AUTO,
plugins: {
scene: [{ key: "CRTPlugin", plugin: CRTPlugin, mapping: "crt" }],
},
scene: [MyScene],
};
new Phaser.Game(config);In your scene, simply call crt.enable with your options:
export class MyScene extends Phaser.Scene {
create() {
// Enable for all cameras
this.crt.enable({
curvature: 0.18,
scanlineIntensity: 0.16,
wobbleAmp: 0.001,
});
// Toggle with a key
const key = this.input.keyboard?.addKey("P");
key?.on("down", () => this.crt.toggle());
// Live tweak
this.time.addEvent({
delay: 2000,
loop: true,
callback: () => this.crt.update({ wobbleAmp: Math.random() * 0.002 }),
});
// Disable for all cameras
this.crt.disable();
}
}curvature(0โ0.4)scanlineIntensity(0โ0.5)scanlineFreq(1.5โ4.0)wobbleAmp(0โ0.003)wobbleFreq(10โ80)vignette(0โ1)desaturate(0โ1)gamma(0.8โ1.2)maskStrength(0โ0.1)noise(0โ0.3)detune(0โ0.05) enables a sweeping horizontal sawtooth displacement
Open demo/index.html locally or serve the folder.
Run npm test to run a minimal test suite.
Run npm run benchmark to test the plugin's performance. Expect less than 10ms to do 100,000 iterations.
npm i
npm run buildMIT ยฉ Spikything.com