Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Threshold Filter #34

Open
nathanielhudson opened this issue Sep 7, 2017 · 7 comments
Open

Add a Threshold Filter #34

nathanielhudson opened this issue Sep 7, 2017 · 7 comments

Comments

@nathanielhudson
Copy link

Hello!

As per pixijs/pixijs#2297 it would be nice to have a threshold filter with a configurable threshold point. This has applications in a few other effects (bloom-like effects, faux-metaball effects, image processing).

Thank you!

@bigtimebuddy
Copy link
Member

Would welcoming a PR for this. Here's a guide to adding new filters to this repo: https://github.com/pixijs/pixi-filters/wiki/Adding-Filters

@finscn
Copy link
Contributor

finscn commented Oct 16, 2017

I read the API document of flash about threshold : http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html#threshold() . I think it's easy.
I will try to implement it next week.
I want to call it ColorThresholdFilter.
Because It's similar to ColorReplace & ColorAdjust , and ThresholdFilter is too abstract. User can't know the threshold of what.

So I decide name it ColorThresholdFilter.

ColorThresholdFilter(operation:number, threshold:number, color:number = 0, mask:number = 0xFFFFFFFF, copySource:boolean = false)

@finscn
Copy link
Contributor

finscn commented Oct 17, 2017

I'm wrong . it's not easy. because glsl no Bitwise Operations.
We can create some functions to do that , but with bad performance.

@tgrajewski
Copy link

Threshold can be easily achieved with the ColorMatrixFilter from PIXI.

@eXponenta
Copy link
Contributor

Threshold for all operations is not easy.
For specific masks that different of "ff" for each channels need use lookup table, or unroll bitwise operations onto division.

BUT!
This is only webgl1 problem, for es300 all is ok and bitwise operations is supported (by spec).

@eXponenta
Copy link
Contributor

Threshold can be easily achieved with the ColorMatrixFilter from PIXI.

So, only for src == color with replacement onto 0 or FFFFFFFF

Not good choice :)

@tgrajewski
Copy link

OK, maybe I've misunderstood something, I don't know how threshold from Flash work. What I meant is that color threshold like the one used in GIMP or Photoshop can be easily achieved with color matrix, where each color is converted to black or white depending on its brightness. No bitwise operations needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants