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

[REQUEST] Wish for a Posterization filter? #145

Open
partynikko opened this issue Jan 30, 2018 · 3 comments
Open

[REQUEST] Wish for a Posterization filter? #145

partynikko opened this issue Jan 30, 2018 · 3 comments

Comments

@partynikko
Copy link

partynikko commented Jan 30, 2018

As I have been using quite some pixi-filters I thought it would be fun and interesting to develop my own for the sake of practicing creating fragment shaders.

I have created a posterization filter which limits the amount of colors to a chosen palette (either own supplied or from a preset) or if no palette is chosen; limits the original colors. It works by mapping the current pixel color to the closest matching color in the palette.

Note: I have tried various different ways to find the best matching color, including converting from sRGB to XYZ to LAB for the comparison. However, I got the best results doing a simple euclidean distance comparison in the sRGB space and this also seems to be what Adobe Illustrator is using for its' posterization effect (I have compared results with my shader and the results are identical). Hence I think the approach is good.

Some examples and with presets I've created:

Original:
bunny4

No palette supplied (reduced original colors):
bunnynopalette

NES:
bunnynes

Gameboy:
bunnygameboyy

Night:
bunnynight

Patagonia:
bunnypatagonia

Solarized:
bunnysolarized

Autumn:
bunnyautum

Blue:
bunnyblue

Accent:
bunnyaccent

And you can supply any palette of your own with any amount of colors, if you don't choose any of the presets above. Endless options and opportunities.

Now to the main question; would you be interested in having this as a filter? If so I'll simply do a PR of it and be more than happy to share it :)

@ivanpopelyshev
Copy link
Contributor

Right now pixi-filters is good enough to accept any good filters. Look at https://github.com/pixijs/pixi-filters/tree/master/filters/multi-color-replace.

Make PR or ask @finscn to help you with it. The thing is, we need palette chooser for the demo, and it'll require some changes in UI.

@partynikko
Copy link
Author

@ivanpopelyshev Do you mean I should have a look at the one you supplied for inspiration how to implement it as a filter, or do you mean my posterization filter is too similar? 🤔

I'll do a PR and gladly accept a code review and suggestions how do improve the implementation.

@finscn
Copy link
Contributor

finscn commented Jan 30, 2018

@Nikkop , I think the meaning of ivan is the first one.

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

4 participants