Jump to content

Custom filter coord issue


Recommended Posts


i have a problem with a custom filter.

I notice that the result of this simple custom filter change when the sprite are moved from js.

Seems to be that vTextureCoord are affected by the position.x value:

when i change its value, the filter render a different image.

precision mediump float;

uniform float frequency;
uniform float amplitude;
varying vec2 vTextureCoord;
uniform sampler2D uSampler;

float upDown(float v) {
  return sin(v) * .5 + .5;

void main (void) {

    vec2 uv = vTextureCoord;

    float t1 = frequency * 0.2;
    float t2 = frequency * 0.35;
    float v = uv.y;
    float h = uv.x;

    float off1 = sin((h + 0.4) * mix(1., 6., upDown(t1))) * amplitude * 0.5;
    float off2 = sin((h + 0.8) * mix(3., 8., upDown(t2))) * amplitude  * 1.5;
    float off3 = sin((h) * mix(1., 2., upDown(t1))) * amplitude  * 0.5;

    uv = vec2(
        h + off1 + off2 + off3,

    gl_FragColor = texture2D(uSampler, uv);


How can I get the same image, even moving or scaling the sprite?

Thanks in advance

Link to comment
Share on other sites

Anyway, here's the article, I hope you read it already: https://github.com/pixijs/pixi.js/wiki/v4-Creating-Filters#fitting-problem

Your second issue is about "dontFit". First is about map/unmap.

With the nature of your issue, only one sprite in container , may be its better to use renderer plugin instead, it doesnt have map/unmap and fitting problem. It has more lines of code, but less problems: https://github.com/pixijs/pixi-plugin-example/

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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