Page 1 of 1

Support blend_mode in Types/IconData

Posted: Tue May 12, 2020 10:29 pm
by kirazy
Item in world (defined with pictures)
Image

Item in world, looking very faded (defined with icons)
Image

Item in inventory, looking very faded (defined with icons)
Image

Looking into it, the difference in outcomes is because blend_mode is not a supported property for IconData.

Is it possible to add it as a supported property?

(Or is there another way to do this that allows me to have my cake and eat it too?)

Re: Support blend_mode in Types/IconData

Posted: Wed May 13, 2020 6:24 am
by posila
Blend mode switching is bad for sprite batching, so it won't be added for icons, sorry.

You can achieve additive blending by just setting the alpha value of your tint to zero, due to the game expecting all color values have premultiplied alpha: https://www.factorio.com/blog/post/fff-172

That is actually what the game will do when loading sprite definition with additive blend mode - uses default premultiplied alpha blending and overrides tint alpha to zero without modifying color channels. That way sprites with default blend mode and additive blend mode can be batched into single draw call.

EDIT: In addition to that ... it would make it impossible to bake the layered icons in the future, as different blending modes might not be associative.

Re: Support blend_mode in Types/IconData

Posted: Wed May 13, 2020 6:29 am
by kirazy
posila wrote: Wed May 13, 2020 6:24 amYou can achieve additive blending by just setting the alpha value of your tint to zero
Ah! That worked. :D Thanks a lot.