Scale in Lua VS Scale in Image Manipulation program

Place to get help with not working mods / modding interface.
Post Reply
Suf
Long Handed Inserter
Long Handed Inserter
Posts: 76
Joined: Fri Jul 10, 2020 5:07 am
Contact:

Scale in Lua VS Scale in Image Manipulation program

Post by Suf »

Hi

Is there any benefit/downside from using the same high resolution image which is innately scaled down by half in entity.lua and use it again with the same scale for low resolution version?
From the player perspective they both scaled the same and for modding i could use an image manipulation program to scale it down by half and then in Lua i'd leave the scale unused, but the question here would that affect anything performance wise?

Thanks in Advance.

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

Re: Scale in Lua VS Scale in Image Manipulation program

Post by Deadlock989 »

You've phrased this in a way which is hard to understand but based on a surface reading of what you've said the answer is no, there would be no benefit. There would be no point in specifying an hr_version with the same scale and dimensions as the regular version. Further, it would be a waste of your time: the hr_version is not mandatory, if you don't need it or want it, don't bother with the hr_version property.
Image

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3699
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Scale in Lua VS Scale in Image Manipulation program

Post by DaveMcW »

The downside is it uses 4x the VRAM for people on low resolution graphics. Running out of VRAM is a big peformance hit.

Suf
Long Handed Inserter
Long Handed Inserter
Posts: 76
Joined: Fri Jul 10, 2020 5:07 am
Contact:

Re: Scale in Lua VS Scale in Image Manipulation program

Post by Suf »

Deadlock989 wrote:
Sun Apr 11, 2021 9:46 am
You've phrased this in a way which is hard to understand but based on a surface reading of what you've said the answer is no, there would be no benefit. There would be no point in specifying an hr_version with the same scale and dimensions as the regular version. Further, it would be a waste of your time: the hr_version is not mandatory, if you don't need it or want it, don't bother with the hr_version property.
But isn't the result the same?let's say i've made an HR sprite sheet lab that is 1000 Width 1000 Hight and scaled it down with the same animations(which probably would be demanding for performance)to 500 Width and 500 Hight for low resolution ,wouldn't that be pointless as well?what i'm trying to say here is low resoultion isn't just scaling down the sprite sheet,it would have less of animation that would impact the performance heavily,right?

But if HR_version isn't mandatory that means the animations i've made could impact those who would play on normal sprite mode,no?
DaveMcW wrote:
Sun Apr 11, 2021 9:53 am
The downside is it uses 4x the VRAM for people on low resolution graphics. Running out of VRAM is a big performance hit.
So then i have to cut the animation by half as well,make it less demanding overall to make it an actual low resolution sprite sheet.

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

Re: Scale in Lua VS Scale in Image Manipulation program

Post by Deadlock989 »

Suf wrote:
Sun Apr 11, 2021 11:48 am
But isn't the result the same?let's say i've made an HR sprite sheet lab that is 1000 Width 1000 Hight and scaled it down with the same animations(which probably would be demanding for performance)to 500 Width and 500 Hight for low resolution ,wouldn't that be pointless as well?what i'm trying to say here is low resoultion isn't just scaling down the sprite sheet,it would have less of animation that would impact the performance heavily,right?

But if HR_version isn't mandatory that means the animations i've made could impact those who would play on normal sprite mode,no?
Sorry - I'm still not sure what you're asking, to be honest. Low resolution sprites are usually scaled at 32 pixels per tile width, so a 32x32 sprite would cover one tile - that is scale 1. High resolution is 64x64 - that is scale 0.5. So HR sprites use up 4x as much video memory because it takes four (2x2) HR pixels to cover 1 (1x1) LR pixel. You can work to any other ratio or resolution you like, it's up to you, but that is the precedent set by vanilla (with a couple of exceptions like inserter arms which have to stretch oddly so need a higher base resolution and lower scale).

Yes, if you care about people that play on computers that can only handle a handful of low resolution sprites, you should provide low resolution sprites for them. Every frame of animation then takes the same bite out of the VRAM cherry (although any dead transparent space around the sprite is automatically cropped by the sprite loader) so again, if you want your mod to run on the most potato-y potato out there, you would drop some of the frames in the animation as well, or just not animate it at all. The downside is that the majority of people with actual gaming PCs then have to download a bunch of low resolution stuff their game will never even use.

Personally I'm not bothered about low res, I don't think there are that many people playing modded Factorio without a dedicated GPU and VRAM. Anecdotal evidence for this is a mod I was involved with which had (and still has) a mistake in one of its low resolution sprite sheets, there were two reports about it spaced 20 months apart while there were hundreds of other reports about the mod in the same time period. But this is not a popular view.
Image

Suf
Long Handed Inserter
Long Handed Inserter
Posts: 76
Joined: Fri Jul 10, 2020 5:07 am
Contact:

Re: Scale in Lua VS Scale in Image Manipulation program

Post by Suf »

Deadlock989 wrote:
Sun Apr 11, 2021 3:02 pm
Suf wrote:
Sun Apr 11, 2021 11:48 am
But isn't the result the same?let's say i've made an HR sprite sheet lab that is 1000 Width 1000 Hight and scaled it down with the same animations(which probably would be demanding for performance)to 500 Width and 500 Hight for low resolution ,wouldn't that be pointless as well?what i'm trying to say here is low resoultion isn't just scaling down the sprite sheet,it would have less of animation that would impact the performance heavily,right?

But if HR_version isn't mandatory that means the animations i've made could impact those who would play on normal sprite mode,no?
Sorry - I'm still not sure what you're asking, to be honest. Low resolution sprites are usually scaled at 32 pixels per tile width, so a 32x32 sprite would cover one tile - that is scale 1. High resolution is 64x64 - that is scale 0.5. So HR sprites use up 4x as much video memory because it takes four (2x2) HR pixels to cover 1 (1x1) LR pixel. You can work to any other ratio or resolution you like, it's up to you, but that is the precedent set by vanilla (with a couple of exceptions like inserter arms which have to stretch oddly so need a higher base resolution and lower scale).

Yes, if you care about people that play on computers that can only handle a handful of low resolution sprites, you should provide low resolution sprites for them. Every frame of animation then takes the same bite out of the VRAM cherry (although any dead transparent space around the sprite is automatically cropped by the sprite loader) so again, if you want your mod to run on the most potato-y potato out there, you would drop some of the frames in the animation as well, or just not animate it at all. The downside is that the majority of people with actual gaming PCs then have to download a bunch of low resolution stuff their game will never even use.

Personally I'm not bothered about low res, I don't think there are that many people playing modded Factorio without a dedicated GPU and VRAM. Anecdotal evidence for this is a mod I was involved with which had (and still has) a mistake in one of its low resolution sprite sheets, there were two reports about it spaced 20 months apart while there were hundreds of other reports about the mod in the same time period. But this is not a popular view.
Yeah low resolution images double every entity sprite sheet and that would affect the size of the mod and if the animation adjustment involved that will also consume more time to make them not that performance impacting ,but as exchange not everyone could play the mod.Anyway i might make a sub mod for low-resolution later so it wont affect anything for the main mod size.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Scale in Lua VS Scale in Image Manipulation program

Post by eradicator »

Lua Scale: Makes the image appear smaller but uses same amount of VRAM. If you zoom in very close to a building there's a clear visual difference between a lua-scaled HQ and an image-scaled LQ.

Image Scale: Reduces file size, VRAM usage and visual quality. If you use a high-quality downscaling algorythim this could look better than lua-scale at zoom=1.0. But most of the time one doesn't play at exactly 1.0 anyway.


Btw, if you happen to use the exact same sprite in several places it's actually better to use lua-scale because then the sprite has to be loaded only once. Main use-case for this are differently sized icons for the same thing. I.e. when you need a tech + entity + item icon. Icons aren't generally large so the effect isn't really that big (not sure if mipmaps do that automatically now?).

Suf wrote:
Sun Apr 11, 2021 3:49 pm
Anyway i might make a sub mod for low-resolution later so it wont affect anything for the main mod size.
If you built the mod with that in mind you could probably make an automated script that generates the whole low-res mod automatically. Not sure how Space Exploration does it, but it's the only mod I can come up with on the spot that does it at all.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Suf
Long Handed Inserter
Long Handed Inserter
Posts: 76
Joined: Fri Jul 10, 2020 5:07 am
Contact:

Re: Scale in Lua VS Scale in Image Manipulation program

Post by Suf »

eradicator wrote:
Sun Apr 11, 2021 9:19 pm
Lua Scale: Makes the image appear smaller but uses same amount of VRAM. If you zoom in very close to a building there's a clear visual difference between a lua-scaled HQ and an image-scaled LQ.

Image Scale: Reduces file size, VRAM usage and visual quality. If you use a high-quality downscaling algorythim this could look better than lua-scale at zoom=1.0. But most of the time one doesn't play at exactly 1.0 anyway.


Btw, if you happen to use the exact same sprite in several places it's actually better to use lua-scale because then the sprite has to be loaded only once. Main use-case for this are differently sized icons for the same thing. I.e. when you need a tech + entity + item icon. Icons aren't generally large so the effect isn't really that big (not sure if mipmaps do that automatically now?).

Suf wrote:
Sun Apr 11, 2021 3:49 pm
Anyway i might make a sub mod for low-resolution later so it wont affect anything for the main mod size.
If you built the mod with that in mind you could probably make an automated script that generates the whole low-res mod automatically. Not sure how Space Exploration does it, but it's the only mod I can come up with on the spot that does it at all.
Very interesting and i would take a look at space exploration to see if i can load the images from sub mod.Thanks for the suggestion :)

Post Reply

Return to “Modding help”