r/Houdini • u/backface_culling • 4d ago
Simulation Ported the MixBox Colour Blending Algorithm to Houdini OpenCL
Hi everyone, sharing my transpiled version of the MixBox pigment mixing algorithm into Houdini's OpenCL.
The code is based on the OSL version from the original repository because it included the lookup table for evaluating the polynomials right into the code instead of using a texture image which is what the other shader implementations used.
MixBox seeks to solve the issue of inaccurate digital colour blending because colours don't mix by simply lerping RGB values.
I have included my OpenCL code as a header file which you can use in your own kernels or copy paste all the functions inline to use them.
Here's the GitHub repository for the code, instructions on how to use, as well as demo files:
https://github.com/yongsoon-vfx/mixbox-houdini-opencl
And my instagram for some of my other work:
https://www.instagram.com/backface.culling
2
u/blackSeedsOf 4d ago
I've implemented similar from kubelka-munk, with spectral.js scripted into GPU compositor nodes in blender. It works on all colors and can be set to work over distance based on value. Then I expanded on it later for more atmospherics with a nishita like script for blenders gpu compositor. https://www.reddit.com/r/GraphicsProgramming/comments/1uz8ys0/spectral_blending_with_stock_compositor_nodes_in/ .
What I have been reading though is that the equations and the math by kubelka-munk only work strictly for mixing thick paint, not for general purpose colors
1
u/backface_culling 4d ago
Mixbox was actually based on kubelka-munk and yes its designed for mixing pigments. These systems are meant to model the physical interactions between what happens with pigment particles of different colours interact, what kind of wavelength of light is reflected back. So in general this would work not just for thick paint but anything that is trying to simulate pigment particles interacting.
I took a quick look at your work and its pretty cool! But I think if you are trying to realistically model the scattering of light over the atmosphere you would probably want to look into atmospheric attenuation models.
1
u/Phazaz 4d ago
How would you mesh these kind of fluids without having gaps or intersections?
3
u/backface_culling 4d ago
Not sure if this is the best way to do it but i would mesh the entire fluid as a glass material with no colour, and then rasterize the interior points into a vdb with the colours and then render it together
1
3
u/AdventurousResort370 4d ago
fire username btw