Skip to content

Inverse

Introduction

Inverse color post processing filter.

  • Author: Rex
  • A post-fx shader effect

Usage

Sample code

Install plugin

Load minify file

  • Load plugin (minify file) in preload stage
    scene.load.plugin('rexinversepipelineplugin', 'https://raw.githubusercontent.com/rexrainbow/phaser3-rex-notes/master/dist/rexinversepipelineplugin.min.js', true);
    
  • Apply effect
    • Apply effect to game object
      var pipelineInstance = scene.plugins.get('rexinversepipelineplugin').add(gameObject, config);
      
    • Apply effect to camera
      var pipelineInstance = scene.plugins.get('rexinversepipelineplugin').add(camera, config);
      

Import plugin

  • Install rex plugins from npm
    npm i phaser3-rex-plugins
    
  • Install plugin in configuration of game
    import InversePipelinePlugin from 'phaser3-rex-plugins/plugins/inversepipeline-plugin.js';
    var config = {
        // ...
        plugins: {
            global: [{
                key: 'rexInversePipeline',
                plugin: InversePipelinePlugin,
                start: true
            },
            // ...
            ]
        }
        // ...
    };
    var game = new Phaser.Game(config);
    
  • Apply effect
    • Apply effect to game object
      var pipelineInstance = scene.plugins.get('rexInversePipeline').add(gameObject, config);
      
    • Apply effect to camera
      var pipelineInstance = scene.plugins.get('rexInversePipeline').add(camera, config);
      

Import class

  • Install rex plugins from npm
    npm i phaser3-rex-plugins
    
  • Add to game config
    import InversePostFx from 'phaser3-rex-plugins/plugins/inversepipeline.js';
    var config = {
        // ...
        pipeline: [InversePostFx]
        // ...
    };
    var game = new Phaser.Game(config);
    
  • Apply effect
    • Apply effect to game object
      gameObject.setPostPipeline(InversePostFx);
      
    • Apply effect to camera
      camera.setPostPipeline(InversePostFx);
      

Apply effect

  • Apply effect to game object. A game object only can add 1 inverse effect.
    var pipelineInstance = scene.plugins.get('rexInversePipeline').add(gameObject, {
        // intensity: 1,
    
        // name: 'rexInversePostFx'
    });
    
    • intensity : 0(original color) ~ 1(inverse scale). Default value is 1.
  • Apply effect to camera. A camera only can add 1 inverse effect.
    var pipelineInstance = scene.plugins.get('rexInversePipeline').add(camera, config);
    

Remove effect

  • Remove effect from game object
    scene.plugins.get('rexInversePipeline').remove(gameObject);
    
  • Remove effect from camera
    scene.plugins.get('rexInversePipeline').remove(camera);
    

Get effect

  • Get effect from game object
    var pipelineInstance = scene.plugins.get('rexInversePipeline').get(gameObject)[0];
    // var pipelineInstances = scene.plugins.get('rexInversePipeline').get(gameObject);
    
  • Get effect from camera
    var pipelineInstance = scene.plugins.get('rexInversePipeline').get(camera)[0];
    // var pipelineInstances = scene.plugins.get('rexInversePipeline').get(camera);
    

Intensity

  • Get
    var intensity = pipelineInstance.intensity;
    
  • Set
    pipelineInstance.intensity = intensity;
    // pipelineInstance.intensity += value;
    
    or
    pipelineInstance.setIntensity(radius);
    
    • intensity : 0(original color) ~ 1(inverse color)