Questions about mipmapped icons (@posila)

Place to post guides, observations, things related to modding that are not mods themselves.
Post Reply
User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Questions about mipmapped icons (@posila)

Post by Deadlock989 »

0.18 has introduced 4-level mipmapped icons for the entire vanilla set. These are a set of 64x64, 32x32, 16x16 and 8x8 versions of the icon staggered next to each other in a 120x64 canvas.

I have some (relatively shallow) understanding of what mipmaps are for and I've read the old FFF about the issues they are intended to solve. The TL;DR, I think, is that it is really useful for hand-crafted icons when you want to preserve some important symbolic detail at lower resolutions - the best example I can think of in Factorio are the assembler icons, which have 1-3 small cogs on them to indicate the tier - downsampling them just mushes the cogs together. (Ironically, this is an icon that is almost never shipped around on belts in large quantities.) Other things with finicky detail might benefit, like wooden power poles, as long as you have someone prepared to adjust them all by hand/eye.

The current set of 0.18 stock icons ... no easy to way to say it ... they don't look great at 200% GUI scale on a 4K monitor. In fact they look noticeably worse than 0.17 in my view, but that's partly the new colour grading. The 64x64 versions within the mipmaps all look like upscaled 32x32 ones, with the exception of the ores. I'm assuming that these are placeholders, to get the system in place, with updates to the assets to come.

So I have a mod which provides several hundred new 64x64 icons. I have written a Python script which can easily mimic the 4-level mipmap format used by vanilla - it does this by downscaling the 64x64 version three times, using Lanczos resampling. So these are not icons which are going to be distinguished by level in any way, they are just resamples. (I looked at getting Blender to render and composite them at the four levels within an image, but there's absolutely no visible difference and it's much slower.) There is no chance in hell I'm going to customise any of them by level. I'm now faced with adjusting a few hundred prototypes to include the mipmap count parameter.

My question is - should I actually bother with any of this? I ran some tests with mipmapped and non-mipmapped version of the same icons. My understanding (may be wrong) is that if you supply a non-mipmapped icon, the game automatically produces its own resampled mipmap levels during atlas creation at game load. I couldn't see any visual differences at any zoom level between the Lanczos mipmapped icons and the single level icons. There was no noticeable performance benefit either, although I didn't attempt any kind of stress test, it was just a typical factory scene with a reasonable amount of stuff on belts. And the resulting filesize is larger (though not by all that much really, even with 500+ icons bumped up to 120x64).

Is there some benefit to all this potential work that I'm not understanding? e.g. to people with potatos?
Image

posila
Factorio Staff
Factorio Staff
Posts: 5201
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: Questions about mipmapped icons (@posila)

Post by posila »

Deadlock989 wrote:
Wed Jan 29, 2020 2:54 pm
My question is - should I actually bother with any of this? I ran some tests with mipmapped and non-mipmapped version of the same icons. My understanding (may be wrong) is that if you supply a non-mipmapped icon, the game automatically produces its own resampled mipmap levels during atlas creation at game load. I couldn't see any visual differences at any zoom level between the Lanczos mipmapped icons and the single level icons. There was no noticeable performance benefit either, although I didn't attempt any kind of stress test, it was just a typical factory scene with a reasonable amount of stuff on belts. And the resulting filesize is larger (though not by all that much really, even with 500+ icons bumped up to 120x64).

Is there some benefit to all this potential work that I'm not understanding?
Correct. The game will resample the icons to create all mipmap levels it needs, so providing custom mipmaps is an optional override of this mechanism. The game will use bilinear filtering, which usually produces worse results than Lanczos. If you can't see difference between in-game generated and custom generated mipmaps, than there is no benefit for defining custom ones.
Deadlock989 wrote:
Wed Jan 29, 2020 2:54 pm
The current set of 0.18 stock icons ... no easy to way to say it ... they don't look great at 200% GUI scale on a 4K monitor. In fact they look noticeably worse than 0.17 in my view, but that's partly the new colour grading. The 64x64 versions within the mipmaps all look like upscaled 32x32 ones, with the exception of the ores. I'm assuming that these are placeholders, to get the system in place, with updates to the assets to come.
Also correct. They are just upscaled old icons. Because of 71586, we felt it'll be better if we drop in final icon defintions in 0.18.0 to minimize potential mod breakage later on. Now with the campaign completely cancelled, Vaclav is 100% back on working on the new icons, so they might come earlier in 0.18 release cycle than we originally expected.

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Re: Questions about mipmapped icons (@posila)

Post by Deadlock989 »

Thanks, that helps. Really looking forward to the icon update and character GUI updates.

I guess, since I'm overriding some vanilla icon paths anyway, I still have to set the mipmap count in the end, whether that's 0 or 4 I guess, so will probably just have to bite the bullet.
Image

posila
Factorio Staff
Factorio Staff
Posts: 5201
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: Questions about mipmapped icons (@posila)

Post by posila »

Deadlock989 wrote:
Wed Jan 29, 2020 3:27 pm
I guess, since I'm overriding some vanilla icon paths anyway, I still have to set the mipmap count in the end, whether that's 0 or 4 I guess, so will probably just have to bite the bullet.
You don't have to, but it's better if you do. Thank you!

User avatar
snouz
Inserter
Inserter
Posts: 27
Joined: Sun Jan 03, 2021 6:01 pm
Contact:

Re: Questions about mipmapped icons (@posila)

Post by snouz »

Sorry to dig an old thread, I have a additional questions.

Is there a performance or loading time hit from defining or not making mipmaps?

Also, is there a consequence to defining icon_mipmaps = 4 then just not include them in the image?
Graphically contributed to : Bio Industries (soon) | Warehousing | MFerrari's mods | Brevven's mods | Bob Artisanal Reskins | Mining Drones | Teleporters | Emoji signals

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Re: Questions about mipmapped icons (@posila)

Post by Deadlock989 »

I can't answer with posila's authority but these are observations / educated guesses.
snouz wrote:
Sun Dec 19, 2021 4:27 pm
Sorry to dig an old thread, I have a additional questions.

Is there a performance or loading time hit from defining or not making mipmaps?
If there is it must be pretty minimal. Either the mipmaps are loaded from disk or generated on the fly. There are not that many icons in vanilla; even with a mod which provides a lot more, the total time to process all mipmaps on my system is less than three tenths of a second. Swings and roundabouts, if amoebae played on swings and roundabouts.
Also, is there a consequence to defining icon_mipmaps = 4 then just not include them in the image?
Just some log spam, e.g.

Code: Select all

38.392 Warning! Sprite at {0,0; 32x32} from __creative-mod__/graphics/icons/duplicator.png is defined with 4 mipmap levels, but level 1 is expected to be at {32,0; 16x16} which is out of bounds of the source image.
Image

User avatar
snouz
Inserter
Inserter
Posts: 27
Joined: Sun Jan 03, 2021 6:01 pm
Contact:

Re: Questions about mipmapped icons (@posila)

Post by snouz »

Thanks Deadlock !
Graphically contributed to : Bio Industries (soon) | Warehousing | MFerrari's mods | Brevven's mods | Bob Artisanal Reskins | Mining Drones | Teleporters | Emoji signals

Post Reply

Return to “Modding discussion”