What I seek
I'm not sure if "crossfader" is the best way to describe it, but imagine black on one end, white on the other, and a grayscale image in the center. You can lighten or darken the image with a single slider.
I am trying to create a node setup that will either lighten or darken grayscale values, depending on whether an input slider is above or below 0.5. So at a value above 0.5 it would become lighter (with 1.0 fully white), and at a value below 0.5 it would become darker (with 0.0 fully black). If at 0.5 it should remain unchanged.
I'm looking for a solution that will work universally in Cycles or Blender Render, so it shouldn't rely on Shader nodes or other engine-specific nodes, but rather only make use of nodes involving math and color.
Why I need it
I'm trying to emulate the functionality of the Layer Weight node's Blend slider.
I know I can emulate most of the functionality of this node using the technique explained by Jerryno here. This gives output equivalent to the default 0.5 value. However there is no way to lighten or darken the result the way the Blend slider does.
Here is a comparison of the two node setups:
What I've tried
I first tried to use Math nodes to add or subtract from the 0.5 value and mix that, but I soon realized that's not the same process. Next, I tried using MixRGB nodes with Add and Multiply blend modes. I believe this is producing the correct result, but I can't figure out how to control them using a single slider centered at 0.5, since the lightening and darkening rely on different color blend modes. Here is a screen shot of my latest attempt:
The annotation "pretend this cannot be changed" is because, remember, the Layer Weight node will be replaced with the Blender Render incidence angle node setup, which has no Blend slider.
The annotation "how to combine" is because a simple mixing of color values will not suffice. Somehow Multiply must be used if less than 0.5 and Add must be used if higher than 0.5.
There's probably a simple mathematical solution I'm overlooking, but I'm stuck trying to figure out what it might be.
Hopefully I've explained this question well enough. Feel free to ask questions if anything is unclear.