LuaSTG-Sub icon indicating copy to clipboard operation
LuaSTG-Sub copied to clipboard

Multiply blend mode does not work with alpha

Open RyannThi opened this issue 10 months ago • 2 comments

As the title says, multiply blending does not work with alpha on textures, nor does the SetImageState change its opacity. Example:

Image

Code:

SetImageState("image:ReimuFake_1", "mul+mul", Color(100,5,5,5))
Render("image:ReimuFake_1", 700, 155, 0, 1, 1)
SetImageState("image:ReimuFake_1", "", Color(255,255,255,255))
Render("image:ReimuFake_1", 675, 175, 0, 1, 1)

I apologize if there's any known method to avoid this. If there is, I'd love to know about it. And if this is intended behavior, I'd like to know why, too.

RyannThi avatar Mar 11 '25 13:03 RyannThi

In my considerations, the mul blending mode should be used with fully opaque images:

  • with white representing a factor of 1.0
  • black representing a factor of 0.0

If the alpha channel is taken into account, how does it participate in the calculation?

There are some possible calculations:

  1. background-color * image-color * image-alpha ?
  2. lerp(background-color, background-color * image-color, image-alpha) ?

I think these calculations are confusing... So I ignored the alpha channel.

Demonese avatar Mar 14 '25 15:03 Demonese

In LuaSTG-Evo, the multiply blend mode works with alpha, so I assumed the same would apply for Sub 😭 It's confusing to me why it wouldn't, seeing as mul+rev can replicate a similar effect when manually inverting the used texture's color on an image editor.

RyannThi avatar Mar 14 '25 20:03 RyannThi