Color mixing for liquids

Hey, so I'm using the "phy_particle_flag_colourmixing" flag, and it works well except for one detail.
Blue liquids + yellow liquids become gray liquids, rather than green.
I know why it happens. I have a theory that if I could cancel out the R and B values based on the G value (maybe add a bit to it) I could correct the issue.
The problem is, I have no idea how to get into the code behind the flag.

I've been told shaders could probably remedy the issue, though I'd have no idea how, or if that'd cause other color-mixing mishaps.
I could maybe do the blending through collision code, but,
I was wondering if anyone here knows how to modify the values of the flag instead. Or if anyone knows a good equation to convert RGB blending into standard primary color mixing. I know subtractive blending creates black from blue and yellow, so that's a no go.
Any help is highly appreciated. Thank you.
 

NightFrost

Member
I've only once glanced over this stuff and never written any physics code, but I recall the color mix when physics particles collide is an entirely internal process where GML gives you no tools to affect how the mix is made. Your result of yellow + blue = gray suggests that yes, it is a simple additive process where result RGB = particle 1 RGB + particle 2 RGB (or maybe averages the color channels).

Shader: well, sort of. Shader is a graphic process that can alter a texture when it moves from source to destination - that is, gets drawn somewhere - so you could write a shader that looks at pixel colors passing through and have it go, this pixel looks gray...ish enough so I'll tint it green. But to isolate the effect to physics particles only, you'd have to first draw them on separate surface, then draw that through the shader to application surface.
 
Top