Do sub folders improve loading time of images?

Hi all,

I'm working on a kind of picture heavy game. Sometimes, there is a noticeable delay in loading pictures. E.g. when you open a character menu, the player artworks might be loaded in a second later.

I guess the game works through the whole img/pictures folder, searching for the requested image.

Would it help to work with sub folders, to split up the amount of images to check per request?
Or wouldn't that matter much, since the game would check the entire pictures anyway, or the delay has other reasons?

Since it's very risky to change all the picture paths afterwards, I'd like to be sure, this actually might solve the issue.

Thanks,
Zia
Subfolder likely won't make a difference, unless you have an actual plugin that is scanning the directory everytime you open the menu, which is unlikely. An image is loaded with the direct url/filepath, so it's not reading a directory it's simply reading the file right away.

Usually performance issues like you describe are caused by large images, if the images are used often, then it may be a good idea to preload the images when your game boots up.

You can check out Synrec's preloader to help you with that https://synrec.itch.io/rpg-maker-mz-preloader
I guess the game works through the whole img/pictures folder, searching for the requested image.
No, that's not how operating systems work.

Would it help to work with sub folders, to split up the amount of images to check per request?
No.

Or wouldn't that matter much, since the game would check the entire pictures anyway, or the delay has other reasons?
As @inc0der says, it's more likely to do with the size of your images and whether or not they're being cached.

Does your game do the same thing on other people's systems? It could even be a hardware issue.
Thank you. The images in question aren't that big. At least not all of them. Maybe 1 to 4 kb.
I'm pretty sure my hardware is fine. I use the HUD Maker Ultra for some of my menu screens, and that plugin in particular seems to be a little fast sometimes. But I encountered image loading delay in situations w/o HUD Maker Ultra as well.

In some situations I use a script to preload the image. Could someone confirm, that I did it right and this actually does what I think it sould do?

Code:
var variableValue = $gameVariables.value(1105); // Check value of v1105
var imageName = "TradingCard_" + variableValue; // Create file name based on variable

ImageManager.loadPicture(imageName);

If so, I'll add it to more events, with some logic to anticipate, which image is about to be used.
are we talking a compiled game or the test build?
if it's compiled, it could be that the system takes a little longer to decode the package, every time.
if it's an HDD, it could be badly fragmented.

anyway, any on-the-fly heavy image processing should use a preloader... especially with your size of image, it would get rid of any loading time while playing. Just load the whole bunch in memory one time, and keep it there.
Code:
var variableValue = $gameVariables.value(1105); // Check value of v1105
var imageName = "TradingCard_" + variableValue; // Create file name based on variable
ImageManager.loadPicture(imageName);
The first line is unnecessary, and is inaccurate - it's not checking anything, it's just declaring a variable.

You could simply do
Code:
var imageName = "TradingCard_" + $gameVariables.value(1105);
(of course, you also don't need the imageName variable and could just put all of that as the argument for ImageManager).

Also, just calling ImageManager.loadPicture() doesn't change anything unless you're doing it at an actual different time than when you're trying to display the image. You'd need to set something equal to its return value in order to have it wait for the loading to complete. (as far as I know)

This should be done internally by default, inside the drawFace() method - are you using a plugin to customize your menu? If yes, I would suggest fixing the plugin rather than trying to find ways to work around the issue.
Also, just calling ImageManager.loadPicture() doesn't change anything unless you're doing it at an actual different time than when you're trying to display the image. You'd need to set something equal to its return value in order to have it wait for the loading to complete. (as far as I know)

This should be done internally by default, inside the drawFace() method - are you using a plugin to customize your menu? If yes, I would suggest fixing the plugin rather than trying to find ways to work around the issue.

This specific preload is used for a flip card effect. You see the back of the card first, and it will turn into the preloaded card. This is event based. Sure, in this case, there's plenty of time to initialize the image early on, but that's not the case with all of my HUDs using the HUD Maker Ultra for example. It comes with an own editor to build HUDs, converting the result into JSON files. I can't modify the editor.

It contains call ups for images via custom code, like

Code:
return "img/pictures/MonsterAvatar_" + $gameVariables.value(1048) + ".png";

and these take slightly longer than the rest of the HUD layout to load.


PS:

are we talking a compiled game or the test build?

anyway, any on-the-fly heavy image processing should use a preloader... especially with your size of image, it would get rid of any loading time while playing. Just load the whole bunch in memory one time, and keep it there.

It's the test build.
Are you saying there is a field within the HUDMaker interface where you'd paste that line of code?

Or is that a line of code from inside the plugin?

Because that value being returned is just a string that's the filepath - it has to be getting used someplace to load an image.
The HUD Maker comes with a stand alone editor where you can place and modify all kind of HUD elements and configurate them into oblivion. From display conditions to code based context sensitive selection of the needed graphic or text you want to display.
The result is a JSON file, which will interpret my "return"-line to get the specific graphic at the right spot. It comes with coordinates, conditions etc. of course as well.


Unfortunately the author doesn't support it anymore.

Anyway, I will experiment with a preloader plugin, after reading your answers, I'm positive, that it will fix the issues. If not, I'll poke again, thank you!
Yes, it's just that managing preloader plugins can be difficult and it shouldn't be needed if the plugin were written correctly.

But not so many people are willing to try to fix SRD's work for him, and of course that's the most complex one.
@Zia_ you don't really need a preloader plugin per se, if you're not concerned about memory leaks.
you can put a loop at the beginning of the program to just bulk-load all images into memory, and another one at the end before shutdown to clear the memory.
the plugin just gives you the chance to fine-tune what you load, and when.

Original thread: https://forums.rpgmakerweb.com/threads/do-sub-folders-improve-loading-time-of-images.170925/