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

Why mask during colour mixing? #22

Closed
micycle1 opened this issue Feb 7, 2024 · 2 comments
Closed

Why mask during colour mixing? #22

micycle1 opened this issue Feb 7, 2024 · 2 comments

Comments

@micycle1
Copy link

micycle1 commented Feb 7, 2024

I'm looking into porting p5.brush to Java Processing (at least the core bits).

I've tried to get the KM colour blending working first (using MixBox so far), and have a solution based on a double buffer (where the existing graphics/canvas reside in one PGraphics buffer, and the new geometry primitive to blend resides in another, then mixing is ran pixel-wise using a shader on these two).

I have a question about an aspect of the approach you took -- namely, the need to mask the colour-mixing.

I'm failing to see why the whole masking thing is necessary, since the unfilled pixels (e.g. white region in the MaskBuffer below) are transparent and mixing these empty/transparent pixels with the existing canvas fully preserves the canvas' pixel colour values. Am I missing something (other than possible performance improvements)?

image

@acamposuribe
Copy link
Owner

Hi @micycle1 !

Good point...
I originally did this because I used different colours in the mask in order to add effects.
When the pixel had green or blue components, apart from red, I performed specific actions within the shader.
Now I'm not doing that anymore, I just inherited my old approach...
At the end is basically the same, if I'm not understanding you wrongly. The only difference is that your blend color values are in the buffer/texture itself, rather than passed as a uniform. If you want to mix pigments, you still need to do various passes for each of the colours, which is what makes the whole thing a bit slow, particularly for high res canvas.

You are anyway right, maybe I should move this to a more logic approach, less variables.
Thx!

@acamposuribe
Copy link
Owner

On other note, @micycle1, I strongly suggest to try Spectral.js rather than Mixbox.
It's an open source alternative with basically the same functionality, and smaller in size.

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

No branches or pull requests

2 participants