Jump to content

PIXI Filter - access non-premultiplied alpha


Recommended Posts

I've been working with PIXI filters recently.

If I apply the filter to a sprite with alpha, I've noticed that somewhere along the line the alpha gets premultiplied.

For example, I have a test texture with a pixel saved as [255, 255, 255, 128].

When I sample the texture, in a filter Instead of [1.0, 1.0, 1.0, 0.5] the result is [0.5, 0.5, 0.5, 0.5].

How can I turn off this premultiplying behaviour? I've tried 'transparent: false' and 'transparent: "notMultiplied" ' in the webGL renderer settings, but neither of those seemed to make any difference?

Link to comment
Share on other sites

There's no way to turn it off in filters.

I want that feature in v5, but in v4 its that difficult. "if (something.a>0) { vec3 rgb=something.rgb/something.a; ... } else gl_FragColor = ... ;" something like that should work.

Most simplest operations are using (Ra,Ga,Ba,a) because linear filtering needs that. In case of pixi filters, its not needed but we use it just because its easier to maintain the code where (Ra,Ga,Ba,a) is the only case.

A few months ago I've made a patch that allowed pixi to use non-premultiplied textures in sprites, to use with "compressed-textures" plugin. I hope to add it to PIXI.Filter in next release!

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...