[2.0.60] apply_render_tint breaks rendering in additive blend mode

Post your bugs and problems so we can fix them.
Hanodest
Burner Inserter
Burner Inserter
Posts: 7
Joined: Sun Aug 11, 2024 10:55 pm
Contact:

[2.0.60] apply_render_tint breaks rendering in additive blend mode

Post by Hanodest »

Example entity:

Code: Select all

--- @type data.SimpleEntityWithOwnerPrototype
local static_test = {
  type = "simple-entity-with-owner",
  name = "picture_test",
  collision_box = { { -0.9, -0.9 }, { 0.9, 0.9 } },
  selection_box = { { -1, -1 }, { 1, 1 } },
  picture =
  {
    layers = {
      {
        filename = "__Test__/sprites/circle.png",
        width = 64,
        height = 64,
        scale = 1,
        shift = util.by_pixel_hr(-64, 0),
        blend_mode = "additive",
      },
      {
        filename = "__Test__/sprites/circle.png",
        width = 64,
        height = 64,
        scale = 1,
        shift = util.by_pixel_hr(64, 0),
        blend_mode = "additive",
        apply_runtime_tint = true,
      },
    }
  }
}
Simple sprite - white circle in black square. Put twice next to each other, both times with `blend_mode = "additive"`, one time with `apply_runtime_tint = true`.
circle.png
circle.png (709 Bytes) Viewed 114 times
When rendered in game, the non-tinted circle is rendered as expected, but the tinted has a dark square around it.
render_error.png
render_error.png (3.32 KiB) Viewed 114 times
Curiously, the dark square is smaller than the full original image.

Animations have the same exact problem.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15868
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [2.0.60] apply_render_tint breaks rendering in additive blend mode

Post by Rseding91 »

From first thinking about this, I highly suspect this is a "working correctly/you can't do that" scenario. Tinting a black section of the image will virtually always result in it being less-black due to how tints work (a + b / 2). Then you do additive blend rendering and a semi-transparent black section rendered against the normal background gets what you see.

Unless I'm missing something - you simply can't do what you're trying to do.
If you want to get ahold of me I'm almost always on Discord.
Hanodest
Burner Inserter
Burner Inserter
Posts: 7
Joined: Sun Aug 11, 2024 10:55 pm
Contact:

Re: [2.0.60] apply_render_tint breaks rendering in additive blend mode

Post by Hanodest »

The reasons I believe that it's a bug:

- The behavior is different from static tints defined in the prototype (the right circle):
more_tints.png
more_tints.png (4.22 KiB) Viewed 50 times
- The dark square around is smaller than the original image. Here's the same, but with normal blending mode for comparison:
blend_normal.png
blend_normal.png (3.88 KiB) Viewed 50 times
- Regardless of what the final color/alpha of the sprite is, result of the blending in additive mode should never be darker than the background. Which is not the case here.
Tinting a black section of the image will virtually always result in it being less-black due to how tints work (a + b / 2)
Static tints are multiplicative. Which is why default tint of {r=1, g=1, b=1, a=1} leaves the sprite unchanged. So, black color stays always black regardless of the tint.
For runtime tints I'd expect the same.
Post Reply

Return to “Bug Reports”