Horri-fi
Introduction¶
6-in-1 post processing filter
- Bloom
- Chromatic Abberation
- Scanlines
- VHS Distortion
- CRT TV Curve
- Noise
- Vignette
Reference : Horri-fi shader effect
- Author: Rex
- A post-fx shader effect
WebGL only
Only work in WebGL render mode.
Live demos¶
Usage¶
Install plugin¶
Load minify file¶
- Load plugin (minify file) in preload stage
scene.load.plugin('rexhorrifipipelineplugin', 'https://raw.githubusercontent.com/rexrainbow/phaser3-rex-notes/master/dist/rexhorrifipipelineplugin.min.js', true); - Apply effect
- Apply effect to game object
var pipelineInstance = scene.plugins.get('rexhorrifipipelineplugin').add(gameObject, config); - Apply effect to camera
var pipelineInstance = scene.plugins.get('rexhorrifipipelineplugin').add(camera, config);
- Apply effect to game object
Import plugin¶
- Install rex plugins from npm
npm i phaser3-rex-plugins - Install plugin in configuration of game
import HorrifiPipelinePlugin from 'phaser3-rex-plugins/plugins/horrifipipeline-plugin.js'; var config = { // ... plugins: { global: [{ key: 'rexHorrifiPipeline', plugin: HorrifiPipelinePlugin, start: true }, // ... ] } // ... }; var game = new Phaser.Game(config); - Apply effect
- Apply effect to game object
var pipelineInstance = scene.plugins.get('rexHorrifiPipeline').add(gameObject, config); - Apply effect to camera
var pipelineInstance = scene.plugins.get('rexHorrifiPipeline').add(camera, config);
- Apply effect to game object
Import class¶
- Install rex plugins from npm
npm i phaser3-rex-plugins - Add to game config
import HorrifiPostFx from 'phaser3-rex-plugins/plugins/horrifipipeline.js'; var config = { // ... pipeline: [HorrifiPostFx] // ... }; var game = new Phaser.Game(config); - Apply effect
- Apply effect to game object
gameObject.setPostPipeline(HorrifiPostFx); - Apply effect to camera
camera.setPostPipeline(HorrifiPostFx);
- Apply effect to game object
Apply effect¶
- Apply effect to game object. A game object only can add 1 horrifi effect.
var pipelineInstance = scene.plugins.get('rexHorrifiPipeline').add(gameObject, { enable: false, // Bloom bloomEnable: false, bloomRadius: 0, bloomIntensity: 0, bloomThreshold: 0, bloomTexelWidth: 0, bloomTexelHeight: 0, // Chromatic abberation chromaticEnable: false, chabIntensity: 0, // Vignette vignetteEnable: false, vignetteStrength: 0, vignetteIntensity: 0, // Noise noiseEnable: false, noiseStrength: 0, noiseSeed: 0, // VHS vhsEnable: false, vhsStrength: 0, // Scanlines scanlinesEnable: false, scanStrength: 0, // CRT crtEnable: false, crtWidth: 0, crtHeight: 0, // name: 'rexHorrifiPostFx' });enable: Defaultenablevalue for all shader effects.- Bloom
bloomEnable: Settrueto enable bloom effect.bloomRadius,bloomIntensity,bloomThresholdbloomTexelWidth,bloomTexelHeight
- Chromatic abberation
chromaticEnable: Settrueto enable chromatic abberation effect.chabIntensity
- Vignette
vignetteEnable: Settrueto enable vignette effect.vignetteStrength,vignetteIntensity
- Noise
noiseEnable: Settrueto enable noise effect.noiseStrengthnoiseSeed
- VHS
vhsEnable: Settrueto enable VHS effect.vhsStrength
- Scanlines
scanlinesEnable: Settrueto enable Scanlines effect.scanStrength
- CRT
crtEnable: Settrueto enable Scanlines effect.crtWidth,crtHeight
- Apply effect to camera. A camera only can add 1 horrifi effect.
var pipelineInstance = scene.plugins.get('rexHorrifiPipeline').add(camera, config);
Remove effect¶
- Remove effect from game object
scene.plugins.get('rexHorrifiPipeline').remove(gameObject); - Remove effect from camera
scene.plugins.get('rexHorrifiPipeline').remove(camera);
Get effect¶
- Get effect from game object
var pipelineInstance = scene.plugins.get('rexHorrifiPipeline').get(gameObject)[0]; // var pipelineInstances = scene.plugins.get('rexHorrifiPipeline').get(gameObject); - Get effect from camera
var pipelineInstance = scene.plugins.get('rexHorrifiPipeline').get(camera)[0]; // var pipelineInstances = scene.plugins.get('rexHorrifiPipeline').get(camera);
Bloom¶
Enable¶
- Enable
or
pipelineInstance.setBloomEnable(); // pipelineInstance.setBloomEnable(true);pipelineInstance.bloomEnable = true; - Disable
or
pipelineInstance.setBloomEnable(false);pipelineInstance.bloomEnable = false; - Get
var bloomEnable = pipelineInstance.bloomEnable;
Parameters¶
- Set
or
pipelineInstance.setBloomRadius(value); pipelineInstance.setBloomIntensity(value); pipelineInstance.setBloomThreshold(value); pipelineInstance.setBloomTexelSize(width, height);pipelineInstance.bloomRadius = value; pipelineInstance.bloomIntensity = value; pipelineInstance.bloomThreshold = value; pipelineInstance.bloomTexelWidth = width; pipelineInstance.bloomTexelHeight = height; - Get
var bloomRadius = pipelineInstance.bloomRadius; var bloomIntensity = pipelineInstance.bloomIntensity; var bloomThreshold = pipelineInstance.bloomThreshold; var bloomTexelWidth = pipelineInstance.bloomTexelWidth; var bloomTexelHeight = pipelineInstance.bloomTexelHeight;
Chromatic abberation¶
Enable¶
- Enable
or
pipelineInstance.setChromaticEnable(); // pipelineInstance.setChromaticEnable(true);pipelineInstance.chromaticEnable = true; - Disable
or
pipelineInstance.setChromaticEnable(false);pipelineInstance.chromaticEnable = false; - Get
var chromaticEnable = pipelineInstance.chromaticEnable;
Parameters¶
- Set
or
pipelineInstance.setChabIntensity(value);pipelineInstance.chabIntensity = value; - Get
var chabIntensity = pipelineInstance.chabIntensity;
Vignette¶
Enable¶
- Enable
or
pipelineInstance.setVignetteEnable(); // pipelineInstance.setVignetteEnable(true);pipelineInstance.vignetteEnable = true; - Disable
or
pipelineInstance.setVignetteEnable(false);pipelineInstance.vignetteEnable = false; - Get
var vignetteEnable = pipelineInstance.vignetteEnable;
Parameters¶
- Set
or
pipelineInstance.setVignetteStrength(value); pipelineInstance.setVignetteIntensity(value);pipelineInstance.vignetteStrength = value; pipelineInstance.vignetteIntensity = value; - Get
var vignetteStrength = pipelineInstance.vignetteStrength; var vignetteIntensity = pipelineInstance.vignetteIntensity;
Noise¶
Enable¶
- Enable
or
pipelineInstance.setNoiseEnable(); // pipelineInstance.setNoiseEnable(true);pipelineInstance.noiseEnable = true; - Disable
or
pipelineInstance.setNoiseEnable(false);pipelineInstance.noiseEnable = false; - Get
var noiseEnable = pipelineInstance.noiseEnable;
Parameters¶
- Set
or
pipelineInstance.setNoiseStrength(value); pipelineInstance.setNoiseSeed(value);pipelineInstance.noiseStrength = value; pipelineInstance.noiseSeed = value; - Get
var noiseStrength = pipelineInstance.noiseStrength; var noiseSeed = pipelineInstance.noiseSeed;
VHS¶
Enable¶
- Enable
or
pipelineInstance.setVHSEnable(); // pipelineInstance.setVHSEnable(true);pipelineInstance.vhsEnable = true; - Disable
or
pipelineInstance.setVHSEnable(false);pipelineInstance.vhsEnable = false; - Get
var vhsEnable = pipelineInstance.vhsEnable;
Parameters¶
- Set
or
pipelineInstance.setVhsStrength(value);pipelineInstance.vhsStrength = value; - Get
var vhsStrength = pipelineInstance.vhsStrength;
Scanlines¶
Enable¶
- Enable
or
pipelineInstance.setScanlinesEnable(); // pipelineInstance.setScanlinesEnable(true);pipelineInstance.scanlinesEnable = true; - Disable
or
pipelineInstance.setScanlinesEnable(false);pipelineInstance.scanlinesEnable = false; - Get
var scanlinesEnable = pipelineInstance.scanlinesEnable;
Parameters¶
- Set
or
pipelineInstance.setScanStrength(value);pipelineInstance.scanStrength = value; - Get
var scanStrength = pipelineInstance.scanStrength;
CRT¶
Enable¶
- Enable
or
pipelineInstance.setCRTEnable(); // pipelineInstance.setCRTEnable(true);pipelineInstance.crtEnable = true; - Disable
or
pipelineInstance.setCRTEnable(false);pipelineInstance.crtEnable = false; - Get
var crtEnable = pipelineInstance.crtEnable;
Parameters¶
- Set
or
pipelineInstance.setCrtSize(width, height);pipelineInstance.crtWidth = width; pipelineInstance.crtHeight = height; - Get
var crtWidth = pipelineInstance.crtWidth; var crtHeight = pipelineInstance.crtHeight;
Enable all effects¶
- Enable all
pipelineInstance.setEnable(); // pipelineInstance.setEnable(true); - Disable all
pipelineInstance.setEnable(false);