Title. I am testing a new PostFX Shader:
export class PaletteSwapPipeline extends Phaser.Renderer.WebGL.Pipelines.PostFXPipeline {
maxColors: integer;
constructor(game: Phaser.Game) {
const maxColors: integer = 128;
let config = {
game,
fragShader: `
#define SHADER_NAME PALETTE_SWAP
#define MAX_COLORS ${maxColors}
#ifdef GL_FRAGMENT_PRECISION_HIGH
#define highmedp highp
#else
#define highmedp mediump
#endif
precision highmedp float;
uniform sampler2D uMainSampler;
uniform float uStrength;
varying vec2 outTexCoord;
// Effect parameters
uniform vec3 originalPalette[MAX_COLORS];
uniform vec3 newPalette[MAX_COLORS];
void main (void) {
gl_FragColor = texture2D(uMainSampler, outTexCoord);
gl_FragColor.rgb = newPalette[0];
}`
};
super(config);
this.maxColors = maxColors;
}
How do I populate newPalette with different values for different GameObjects? I have tried to put add a postPipelineData object to the GameObject and then read it during onBind() (Which is what the documentation seems to be suggesting to do) but then onBind() is never called???
Trying to set the values during preRender() causes the whole screen to turn that color??? ?
I am using
this.set3fv('newPalette', extractedColors);
is there something wrong with that??? ???
Please help if you can.