3
$\begingroup$

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)

enter image description here

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

1 Answer 1

5
$\begingroup$

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

enter image description here

  • 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:

enter image description here

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!

$\endgroup$
6
  • 1
    $\begingroup$ 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.. $\endgroup$ Jun 13, 2020 at 20:05
  • $\begingroup$ 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 $\endgroup$
    – Noob Cat
    Jun 14, 2020 at 5:50
  • 1
    $\begingroup$ 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. $\endgroup$ Jun 14, 2020 at 7:21
  • 1
    $\begingroup$ @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 :) $\endgroup$ Jan 21 at 12:52
  • 1
    $\begingroup$ 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 $\endgroup$ Jan 21 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.