[1.1.104] Trilinear filtering between incompatible mipmaps

Post your bugs and problems so we can fix them.
Post Reply
xykite
Inserter
Inserter
Posts: 24
Joined: Thu Jul 30, 2020 9:39 pm
Contact:

[1.1.104] Trilinear filtering between incompatible mipmaps

Post by xykite »

This is a minor but noticeable rendering issue that arises from the combination of two non-bugs:
  1. Icons have flags 'linear-minification', 'linear-magnification', 'linear-mip-level'. So if the game interface has a UI scale that results in icon sizes between mipmap levels (i.e. UI scales 75, 125, 150, 175 for most icons) then they are rendered with trilinear filtering.
  2. Some icons (predominantly in __core__/graphics/icons/mip) have mipmaps that do not appear to be proper mipmaps: instead of being downscaled, they look like slightly different renderings at a lower resolution.
Neither 1) nor 2) is an issue by itself: 1) only means you have trilinear filtering with valid mipmaps, and 2) only means when you zoom in or out, you snap between different icons without blending them. However with both at the same time, you are blending two images that are not compatible, which can result in visual artefacts.

The most obvious places where 2) applies are __core__/graphics/icons/mip/slot_ammo_white.png and __core__/graphics/icons/entity/character.png, which are often visible in the GUI. Here I have superimposed the largest mip level (cyan) over the second-largest (red, 2x upscaled with no interpolation).
mipdiff.png
mipdiff.png (4.39 KiB) Viewed 266 times
For slot_ammo_white.png it appears the relative scales and positions of the two mip levels are different, so when they are trilinear-filtered there is visible blurring.

Similarly for character.png, the mipmaps don't quite align. As a result the icon appears blurred at UI scale 125 and the 'ghosting' effect on the RHS is really obvious at UI scale 150.
badblending.png
badblending.png (61.76 KiB) Viewed 266 times
I have checked this issue does not just affect me: looking at screenshots other people have posted on Discord over the past week or so, every image I have found that contains an equipment bar at UI scale 125 or 150 appears to have this problem (red boxes are mine, everything else isn't).
discord.png
discord.png (205.76 KiB) Viewed 266 times
Expected result: Here is what I believe it is meant to look like at scales 125, 150. I have turned off trilinear filtering by removing the linear-mip-level flag from both SpriteOption::Icon, and 'icon' in SpriteFlagHelpers::optionsList. The blurring / ghosting has gone.
noblending.png
noblending.png (59.52 KiB) Viewed 266 times
Attachments
factorio-current.log
(5.3 KiB) Downloaded 15 times
Last edited by xykite on Tue Mar 05, 2024 3:22 pm, edited 3 times in total.

xykite
Inserter
Inserter
Posts: 24
Joined: Thu Jul 30, 2020 9:39 pm
Contact:

Re: Trilinear filtering between incompatible mipmaps

Post by xykite »

Note I believe this report is technically a dupe of 93236. To repro that issue, here is a combinator with a checkmark on it
blurry-check.png
blurry-check.png (33.47 KiB) Viewed 261 times
I believe the reason the glitch is happening is an incorrect mipmap (possibly the only bad one in __base__/graphics/icons). The two levels are superimposed as in my first post.
checked-green.mipdiff.png
checked-green.mipdiff.png (689 Bytes) Viewed 261 times
Here is the same combinator after removing the 'linear-mip-level' flag from SpriteOption::Icon :
nonblurry-check.png
nonblurry-check.png (28.5 KiB) Viewed 261 times
Edit: for completeness here's the fix the other way round - i.e. by correcting the mipmap but keeping trilinear filtering enabled:
checked-green.png
checked-green.png (859 Bytes) Viewed 186 times
fixed-mipmap.png
fixed-mipmap.png (34.54 KiB) Viewed 186 times

Post Reply

Return to “Bug Reports”