Jump to content

How to pass vectors and colors to filters uniforms


Xesenix
 Share

Recommended Posts

var Colorize = function (game) {
    Phaser.Filter.call(this, game);
    this.uniforms.uColor= { type: '3f', value: { r: 0.5, g: 0.5, b: 0.5} };

    this.fragmentSrc = [

        "precision mediump float;",
        "uniform float     uColor;",

        "void main(void) {",
            "gl_FragColor.r = uColor.r;",
            "gl_FragColor.g = uColor.g;",
            "gl_FragColor.b = uColor.b;",
            "gl_FragColor.a = 1.0;",
        "}"
    ];

};

 

It works if i pass each color channel as separate value but i can find combination of type and data structure that would do the same in single object

Link to comment
Share on other sites

uniforms.example1 = { type: '1f', value: 1.0 };
uniforms.example2 = { type: '2f', value: { x: 0.0, y: 0.0 }};
uniforms.example3 = { type: '3f', value: { x: 0.0, y: 0.0, z: 0.0 }};

fragmentSrc = [

    "precision mediump float;",

    "uniform float     example1;",
    "uniform vec2      example2;",
    "uniform vec3      example3;",

    ...

Like this :)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...