Render pipeline

Introduction

Render pipelines for camera of game objects (with texture).

  • Author: Richard Davey

Usage

Add pipeline instance

var config = {
    game: scene.game,
    renderer: scene.game.renderer,
    fragShader: '...'  // GLSL shader
};
var pipelineInstance = new Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline(config);
scene.game.renderer.addPipeline(pipelineName, pipelineInstance);
  • pipelineName : Name of this render pipeline, a string.

Camera effect

  • Add filter
    camera.setRenderToTexture(pipelineInstance);
    
    • pipelineName :
      • A string : Name of this render pipeline
      • A pipeline instance
  • Clear filter
    camera.clearRenderToTexture();
    

Game object effect

  • Add filter
    gameObject.setPipeline(pipelineName);
    
    • pipelineName : Name of this render pipeline, a string.
  • Reset custom render pipeline to defaule render pipeline
    gameObject.resetPipeline();
    
  • Get current name of render pipeline:
    var pipelineName = gameObject.getPipelineName();
    

Set properties of filter

  • Property with 1 value
    • Float
      pipelineInstance.setFloat1(name, value0);
      
    • uniform1fv
      pipelineInstance.setFloat1v(name, value0);
      
    • Int
      pipelineInstance.setInt1(name, value0);
      
  • Property with 2 values
    • Float
      pipelineInstance.setFloat2(name, value0, value1);
      
    • uniform2fv
      pipelineInstance.setFloat2v(name, value0, value1);
      
    • Int
      pipelineInstance.setInt2(name, value0, value1);
      
  • Property with 3 value
    • Float
      pipelineInstance.setFloat3(name, value0, value1, value2);
      
    • uniform3fv
      pipelineInstance.setFloat3v(name, value0, value1, value2);
      
    • Int
      pipelineInstance.setInt3(name, value0, value1, value2);
      
  • Property with 4 values
    • Float
      pipelineInstance.setFloat4(name, value0, value1, value2, value3);
      
    • uniform4fv
      pipelineInstance.setFloat4v(name, value0, value1, value2, value3);
      
    • Int
      pipelineInstance.setInt4(name, value0, value1, value2, value3);
      

Remove pipeline instance

scene.game.renderer.removePipeline(pipelineName);

Get pipeline instance

var pipelineInstance = scene.game.renderer.getPipeline(pipelineName);
  • pipelineInstance : Pipeline instance, or null if not found.

Has pipeline instance

var hasPipelineInstance = scene.game.renderer.hasPipeline(pipelineName);