I’m working with 2D sprites in Unity and using transparency to simulate shadows. However, I’ve run into a problem: when two transparent sprites overlap (e.g., with an alpha value of 0.2), the overlapping area becomes darker due to the blending.
What I want to achieve:
The background should remain visible through the shadows, as intended with transparency.
Overlapping shadows should not stack their transparency and become darker. Instead, the overlap should look seamless.
I’ve tried adjusting the blend modes, but I can’t find the right configuration to prevent the darkening effect.
Does anyone have any suggestions or ideas on how to solve this?
If you can avoid it by just tune your shadow alpha well (it’s possible) then that may be preferable…
BUT yes this is possible but it is a bit more advanced of a subject.
What you do is you take your shadows and put them on a different layer. A different Camera targets this layer (and only this layer). Let’s call that layer Shadow (sensible, I know). This Camera outputs to a Render Texture. Your shadow sprites are full silhouttes of 100% black, not partially transparent.
THEN you remove that layer from your Main Camera.
THEN you have a full-screen sprite on a normal (non-Shadow) layer that samples the shadow render texture in a shader. This displays your shadows. You can then adjust this sprite renderer’s alpha to be whatever semi-transparent you want.