Preload a scene or picture?

  • #1, by Simon_ASAWednesday, 27. January 2016, 11:36 8 years ago
    Hi, I am trying to optimize a few things in my game. I know the useful Action that preloads animations and I am wondering if there is a way to preload a picture or a scene? The reason is that one of my scenes has a resolution of 4000x4000 where we can scroll in all directions, so there's always a slowdown between this scene and the previous one, when it is suddenly loaded in memory. Thanks for your ideas!

    Edit:
    I just thought that I could put this background as the single frame of an active animation, and preload it. But maybe there is another way?

    Edit2:
    It doesn't work. I still need a 4000x4000 picture to define the size of the scene, and this picture is always slow to load, even if it is an empty picture (all black).
    Another idea to preload a scene?

    Great Poster

    321 Posts


  • #2, by Simon_ASAThursday, 28. January 2016, 12:00 8 years ago
    Anyone?

    Great Poster

    321 Posts

  • #3, by afrlmeThursday, 28. January 2016, 12:46 8 years ago
    No, sorry mate. What you mentioned about loading it in as an animation & preloading that is about the only thing I can also think of.

    P.S: Did you already convert the image to webp format? That would reduce loading time of it significantly.

    Imperator

    7278 Posts

  • #4, by Simon_ASAThursday, 28. January 2016, 18:34 8 years ago
    Yeah, all my pics are in webp format.

    Anyway thanks, I think it's not such a big issue, I just wanted to optimize.

    Great Poster

    321 Posts

  • #5, by afrlmeThursday, 28. January 2016, 20:21 8 years ago
    Maybe you could split it into squares & add them as objects? Would reduce the size of each image by quite a lot. Just add a transparent background image at the size you want the scene to be. I don't know if it will help or not, but worth a try maybe?

    Imperator

    7278 Posts

  • #6, by MachtnixThursday, 28. January 2016, 22:18 8 years ago
    I have a funny idea (don't know if it works properly). Ich had the same problem (my scene is only 2500x2500 :-) In my case a full screen animation plays slowly the first time. But after playing once it's speed is correct. Why? I think: It's stored in the cache.
    Your scene should be in memory if a character walks once through the whole scene. So you have to make a cover plate to hide the animations beneath it. I made a covering picture and started the most important animations at the beginning of the game. BTW: Long loading time... After playing all animations once (or - in your case - one character walks from the left side to the right side) the cover disappears, the start scene is shown - and (maybe) the whole scene for the most part is cached. Try it. Don't forget to set your character at the starting point again...
    In R 3.7 this preloading thing works well, but now it doesn't.

    edit: I enlarged the picture cache to 500 MB. It's not that big as you think... believe me. It's full! :-)

    Machtnix

    Thread Captain

    1097 Posts

  • #7, by afrlmeFriday, 29. January 2016, 00:13 8 years ago
    The more stuff you preload the more chance you have of your game running slow further down the line. It's important to manually unload preloaded animations / characters when you no longer need them.

    I believe the game slowing down was an issue Chris (stasis) found out about due to preloading loads of stuff throughout the game without unloading any of it. Eventually after x amount of time (current session) it started slowing down / lagging - my memory is a bit vague on what he said, but was something along the lines of what I'm saying, I think. razz

    Imperator

    7278 Posts

  • #8, by MachtnixFriday, 29. January 2016, 17:24 8 years ago
    I have no idea how this preloading / unloading works. I use it logical: at the beginning of a scene I preload some big animations / pictures, after leaving I unload them. But it doesn't make any difference. Even my animations disappear / don't play. What the hell...? So I kicked it out. In 3.7 it works: I could see the difference, but now??

    I have a backgrund picture with 2500 x 2500. It takes 6819 KB as a png. Wandering around all the objects the character can see must be loaded at the same time also. All outfit moves are slowly at the first time, so I change all outfits once to put them into memory and to play faster! But I'm the developer, not a player, who never would do this.
    For example some animations: 6 MB here or 3 MB there. After making this sightseeing tour I get a full cache of - maybe - 300 MB. Why can't I preload this stuff? It would take more time to load the game, but that's ok. So I have a game with EVERY animation works slowly the first time. If an animation plays just once the player never see the correct speed, because the ani doesn't play twice... :-(

    Machtnix

    Thread Captain

    1097 Posts

  • #9, by afrlmeFriday, 29. January 2016, 17:37 8 years ago
    I do recommend converting all your png files to webp format (lossless quality 10 / 100%). You will notice a significant difference in both file size & loading times.

    Preloading, however... I'm not all that sure about that myself. From what I understand, the engine loads animations frame by frame & then stores them into the temp cache, which means that they should play smoothly for however long they are in the cache for. Preloaded animations / characters are loaded in one go & take how ever long it takes to load the entire animation / character & should remain in the main cache until manually unloaded.

    Other than that, I can't really say as I've not had cause to use the preloading system in the game I'm working on. We try to keep the amount of frames & the file-sizes down as much as possible. We are working at 1080p & often have loads of animations on screen at the same time, but I've optimized them through webp conversion for all images & animations & by reducing the amount of frames used by recycling frames & Lua. We have no duplicated image frames.

    Also one thing to remember is that you are developing a game, not creating an animated movie, so you do not need to use 1 million frames for each animation. 70ms, 100ms, whatever between frames won't look a great deal less smoother to the human eye than say a frame every 16ms (approx 60fps).

    Finally, the thing I mentioned in my earlier post about chopping up the large image into tiles still stands. You could probably reduce the image size by cutting out multiple objects in the final image & adding them to the scene as objects. The less information (details) an image has (the simpler it is) the less the file-size will probably be.

    Imperator

    7278 Posts

  • #10, by MachtnixFriday, 29. January 2016, 18:36 8 years ago
    Also one thing to remember is that you are developing a game, not creating an animated movie, so you do not need to use 1 million frames for each animation.
    Ah, of course not. *lol* But in Germany we say "Kleinvieh macht auch Mist", so if you have a lot of small animations you will have the same huge size at the end of the day.

    I don't know this webp and I think, none of my cut- and picture tools I use supports it. OK, I haven't the newest programs. Maybe it's in Gimp, I haven't check it yet (I hate Gimp...).
    I don't change png into webp in my test games, but I'm looking for a converter tool for the next project. This 2500x2500 thing was only a mini game to test how scrolling works; it's not my favourite way to work... Usually a typical scene is only 1024x720, 800 x 600 or something like that, so my animations and poses don't need huge resolutions... ;-)

    Machtnix

    Thread Captain

    1097 Posts

  • #11, by afrlmeFriday, 29. January 2016, 20:53 8 years ago
    Check the wiki. http://wiki.visionaire-tracker.net/wiki/Image_Encoding

    I've linked the batch tool I use & how to use it.

    P.S: if you were to open up your ved file in a text editor like sublime text, atom or notepad++ then you would be able to do a search & replace of all instances containing ".png" & replace them with ".webp" in a matter of seconds. We do however recommend backing up your ved before opening them up in a text editor as it's very easy to mess something up in the xml code.

    Imperator

    7278 Posts