I want to achieve something like this using blending
I thought that it might be a simple additive shader but after using Blend One One or Blendop Add I get something like this
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.
Sign up to join this communityI know that this topic is old and you finally found a solution but I encountered the same issue and find another solution that also works fine, so I think that it may help other people reading this page.
I'm writing a shader for Godot Engine and I get the same visual artifact as you while merging two distance maps with additive blending (by adding RGB components and applying a clamp in 0-1):
I'm using a basic addition with threshold to avoid values greater than 1:
//min to avoid overflow
float final_value=min(value1+value2,1);
When I export my two distance maps in GIMP and I apply a additive blending I get expected result:
In fact I discover that GIMP and probably photoshop don't just add RGB components when doing additive blending, I investigate by picking pixels before and after blending and result is surprisingly not linear.
After experimentations, I finally found how to get the same result, the key is to do the square root of the sum of squared components:
float final_value=min(sqrt(value1*value1+value2*value2),1);
This isn't something wrong with your blend mode. It's an optical illusion called Mach Bands.
When there's a sudden change in brightness, the change in perceived brightness is exaggerated in the immediate vicinity, making it look like there's a dark line or shadow in the image even if it's not really there.
We can fix this by smoothing out our gradients so they don't have these sharp discontinuities.
Both the top and bottom orbs in the image below use the same additive blending calculation:
The orbs at the top show the same dark ridges as in your example, but the ones at the bottom don't. The reason is I reshaped the gradient slightly in Photoshop, to give it a little "ease out" at the dark end. Like this...
That's enough to smooth out the sharp change in brightness where the gradient bottoms-out to black, so we don't perceive a sharp ridge/dark trough there.
I used Blend SrcColor One and it works fine for me