# 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? – Christopher Bennett Jun 13 at 17:46
• I was trying to avoid using a 3 channel way, like RGB or XYZ (which seem the same thing after all) – Noob Cat Jun 13 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.. – Robin Betts Jun 13 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 – Noob Cat Jun 14 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. – Robin Betts Jun 14 at 7:21
• Your reasoning seems correct, I look forward to someone who may be able to explain the situation better. Your answer enlightened me – Noob Cat Jun 14 at 7:28