# How to emulate MixRGB (Mix) with math node for Grayscale?

I would like to do a little research, and I would like to simulate a MixRgb type node with a mathematical node, to mix BW type maps, since the MixRGB mixes 3 channels, it would be enough for me to mix only one (0-1 Bw), but I'm not sure how to test this with math, I tried the Math node "Multiply Add" I was curious to compare the performance between the RGB type and a node built with single value math, I did not find much about it by looking on the internet Example: (I would like to try to emulate, to compare the performances)

• Is using a vector-math node acceptable for what you're trying to do? Jun 13, 2020 at 17:46
• I was trying to avoid using a 3 channel way, like RGB or XYZ (which seem the same thing after all) Jun 13, 2020 at 18:34

This 'Mix Value' node group will emulate the simple Mix of two values:

• The inputs are all clamped 0-1
• The result is [(1-Fac) * Value 1] + [Fac * Value 2]

You can use this framework to test it:

The outputs of the Mix RGB node and of the combined lower branches, mixing the channels independently, are indistinguishable.

If you want to test the other mix modes, this reference could be handy.You would replace the 'Add' in the node group with the functions described. here's a link to the Blender code, thanks to this answer by @Meng Hui Tan.

Have fun!

• Oops , I left a crazy Fac value in the input node after testing.. I was making sure noithing went out of range in the result.. Jun 13, 2020 at 20:05
• Very interesting, I am doing tests to understand the consumption of resources in comparison with the mixrgb node as regards only black and white, therefore single-value maps. But I don't understand if there is a difference in performance. We should try on big scenes Jun 14, 2020 at 5:50
• I don't know.. I suspect not much difference, since in all the renderer's heavy-lifting areas, the contribution of rays will be evaluated in full RGB? I don't think the renderers can be forced into a monochrome mode.. i think the single channel can only be obtained by extraction from a full-color render. maybe someone who knows will come along. Jun 14, 2020 at 7:21
• @RobinBetts Hi, Mr. Robin Betts, I've been using the function in your answer for a while now, but I've just learnt that it's called ''Linear Interpolation Function''. Function is: (1-x)*a+x*b . You can see more of it right here: youtu.be/NO5JGFJJ_Kk?t=137 I don't want to bother you, just want to share an interesting fact :) Jan 21, 2022 at 12:52
• Hi @Ian! .. or lerp for short, if you ever wind up wanting it in, say, GLSL. Strangely, I've just this minute finished putting another one together for myself for Geometry Nodes.. I think I could have just downloaded my own old answer :D Jan 21, 2022 at 15:10