filters icon indicating copy to clipboard operation
filters copied to clipboard

Add a Threshold Filter

Open nathanielhudson opened this issue 6 years ago • 7 comments

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!

nathanielhudson avatar Sep 07 '17 20:09 nathanielhudson

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

bigtimebuddy avatar Oct 16 '17 15:10 bigtimebuddy

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 avatar Oct 16 '17 17:10 finscn

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

finscn avatar Oct 17 '17 13:10 finscn

Threshold can be easily achieved with the ColorMatrixFilter from PIXI.

tgrajewski avatar Oct 27 '21 15:10 tgrajewski

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 avatar Oct 27 '21 21:10 eXponenta

Threshold can be easily achieved with the ColorMatrixFilter from PIXI.

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

Not good choice :)

eXponenta avatar Oct 27 '21 21:10 eXponenta

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.

tgrajewski avatar Oct 30 '21 10:10 tgrajewski