Hi all,
I want to invert color values of a black and white procedural texture. I wonder why invert node overbrights the image (see below).
Also Substract math node with a value of 0.1 gives somewhat the desired effect. Is this a proper way of doing color inversion?
Don’t trust what you see on the screen!
Basically, the short description of the problem is that the values in your nodes (called scene-referred values at this point) go through a transform before getting displayed on the screen. This is for example to say that you want to make RGB(1.0,1.0,1.0) on the scene appear as full white on the screen, while RGB(0.0,0.0,0.0) appears as pure black.
But the thing is that with the sRGB transform (the one you’re using right now, probably) and most of the other transforms do not map values in a linear way, ie: RGB(0.5,0.5,0.5) in the scene in not a “perfect gray” on the screen! (in other words, it’s not 127,127,127), but instead it is much brighter on the scene, roughly RGB(187,187,187). This is done to keep slightly more definition on brighter areas than darker ones.
This might be a concern only if you were working on what is displayed on your screen, but you are working on scene-referred values and it shouldn’t matter if it looked slightly darker
It is working as it should. If you add 2 invert nodes you return to the same result. The node inverts the values around the center at 0.5 while our eyes that are able to see in the dark a bit better perceive middle grey around 0.18 So when you flip the values around 0.5 the whole of the range perceived as below middle grey(<0.18) and a good chunk more is now in the area where we perceive it as lighter than middle grey.
If I understood correctly, i should trust node/math calculation, rather than what i see on screen/viewport. But then let’s clarify the situation below:
I setup a simple test scene with cube and HDRI environment. Everything is seen as expected, no problem here.
Here is the packed file: invert_node_test.blend (7.0 MB)
I plug the Black & White map into roughness input and again everything is seen as expected, black areas fully/partially reflect the environment and whiter areas don’t.
However when i plug the inverted map into roughness input something is wrong. I expect to see reflections at ‘green areas’ as it can be seen in the first image.
Maybe it’s because the green becomes grey when you use “RGB to BW” node and you were expecting a “pure white”?
You can use for example the alpha channel (that’s slightly faster to process and has less nodes). Just set the alpha of your first color in the color ramp node to what you need like [R:0.0 G:0.0 B:0.0 A:1.0], I suppose, and then set the values on the second one to something like [R:0.0 G:1.0 B:0.0 A:0.0].The Color output won’t be affected at all, but you can then plug the Alpha output directly to your roughness input
I think you’re right. My test scene is a bit misleading then.
I tested again with alpha channels tweaks you suggested and everything working as expected! Seems like that must be the approach when creating roughness & specular maps from procedural textures.
It’s not “the approach”, but “an approach” instead. In fact I’ve never used it before and I just thought of it right as I was looking at your node.
Nothing prevents you from using multiple color ramp nodes (well, it might be insignificantly slower to render, but it will be only milliseconds. Also it’s nothing compared to what a procedural noise texture would need to compute anyway)