Overlapping Shadows: Achieving Consistent Alpha Values in 2D Sprites

Is there a technique or shader setting that can maintain a constant alpha value for overlapping shadow sprites, ensuring that the shadow appearance remains consistent and does not accumulate when multiple sprites overlap?

sorry i’m late, but you can use

            BlendOp Min

in hlsl shaders so it only chooses the lowest value of shadow. this means you can also bake penumbras into shadows or use soft shadows and it will still look nice

alternatively, you can use stencil buffer to prevent drawing on the same fragment twice.

1 Like

Thank you for the response! I attempted both methods, but neither worked perfectly. Could you please review my shaders to see what is wrong?

Method 1 appears to be better, although the shadows are no longer semi-transparent. Method 2 brought additional problems and did not work as well.

Method 1

Method 2

9900558–1429998–ConstantAlphaShadow2.shader (2.4 KB)
9900558–1430001–ConstantAlphaShadow1.shader (2.04 KB)

It appears that eliminating BlendOp Min and implementing Blend One OneMinusSrcAlpha has resolved the issue.

9900627–1430016–ConstantAlphaShadow1.shader (2.01 KB)

1 Like