filters
filters copied to clipboard
Add a Threshold Filter
Hello!
As per https://github.com/pixijs/pixi.js/issues/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!
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
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)
I'm wrong . it's not easy. because glsl no Bitwise Operations. We can create some functions to do that , but with bad performance.
Threshold can be easily achieved with the ColorMatrixFilter from PIXI.
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).
Threshold can be easily achieved with the ColorMatrixFilter from PIXI.
So, only for src == color with replacement onto 0 or FFFFFFFF
Not good choice :)
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.