Jibble

Author Topic: High resolution animation is causing huge lag and errors  (Read 608 times)

Hi!

I have been working on a game with 1600x900 dimensions and photo-realistic sprites. And now that I added a more elaborate intro animation of 500-600 sprites, the animation keeps lagging, the music is faltering and clicking, and repeating itself on one part like a damaged CD! Also I keep getting error reports like this:


Or this:



So my suggestion is to work on the procedure of especially loading Sprites into the Sprite Cache, and maybe the texturing of sprites, to make it possible to have longer-period, high resolution animations without bugs. To make it faster and not mess with the music.
In my game it is so troublesome to make it work. The animation with the lagging music is painful to watch.

For anyone who would like to do a higher resolution, higher quality game in the future, I think it would be very worthwhile to have a more solid engine and improve this part.

« Last Edit: 14 Dec 2019, 23:27 by TheManInBoots »

Re: High resolution animation is causing huge lag and errors
« Reply #1 on: 15 Dec 2019, 08:58 »
Just some math here: 1600x900x4 -> 5.7 MB per sprite
5.7 x 600 frames -> 3.5 GB the full animation.

Crimson Wizard

  • Local Moderator
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    • Lifetime Achievement Award Winner
    • Crimson Wizard worked on one or more games that won an AGS Award!
    •  
    • Crimson Wizard worked on one or more games that was nominated for an AGS Award!
Re: High resolution animation is causing huge lag and errors
« Reply #2 on: 15 Dec 2019, 13:16 »
For the reference, this is the original problem discussion: https://www.adventuregamestudio.co.uk/forums/index.php?topic=57577.0

Re: High resolution animation is causing huge lag and errors
« Reply #3 on: 15 Dec 2019, 15:12 »
I wanted to ask this on the original topic, but it would be nice if there was a small tiny project with high resolution assets that was public (open source) and reproduced all the problems listed, so it would be possible to improve with a target goal.

Crimson Wizard

  • Local Moderator
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    • Lifetime Achievement Award Winner
    • Crimson Wizard worked on one or more games that won an AGS Award!
    •  
    • Crimson Wizard worked on one or more games that was nominated for an AGS Award!
Re: High resolution animation is causing huge lag and errors
« Reply #4 on: 15 Dec 2019, 15:18 »
I wanted to ask this on the original topic, but it would be nice if there was a small tiny project with high resolution assets that was public (open source) and reproduced all the problems listed, so it would be possible to improve with a target goal.

I was going to suggest that, before realizing that this test project won't be TINY :D. Your calculations above show what I mean.

Re: High resolution animation is causing huge lag and errors
« Reply #5 on: 16 Dec 2019, 13:06 »
Just some math here: 1600x900x4 -> 5.7 MB per sprite
5.7 x 600 frames -> 3.5 GB the full animation.

eri0o, the compressed sprite file is 668MB big, uncompressed it's 2 GB big.

The sprites have different sizes, so not every sprite is 5,7 MB big, obviously.

I wanted to ask this on the original topic, but it would be nice if there was a small tiny project with high resolution assets that was public (open source) and reproduced all the problems listed, so it would be possible to improve with a target goal.

Sure, I can upload it and be very precise about what things would be good to improve, no problem. Maybe it would be good to see that the lag occurs in more or less the same way on different computers as well first.

I might look into the script first to make sure that I mark every part to be easier to overview.
I was going to suggest that, before realizing that this test project won't be TINY :D. Your calculations above show what I mean.

I might compress it beforehand.

It will probably just not be right away, and the uploading takes some time as well, but I can definitely do it.
« Last Edit: 16 Dec 2019, 13:08 by TheManInBoots »

Re: High resolution animation is causing huge lag and errors
« Reply #6 on: 16 Dec 2019, 14:20 »
There's one thing I don't remember exactly, but I think hardware accelerated graphics only works with power of 2 , square, sprite sizes on the low level. So 1600x900 would be 2048x2048 in the videocard.
« Last Edit: 16 Dec 2019, 14:22 by eri0o »

Re: High resolution animation is causing huge lag and errors
« Reply #7 on: 16 Dec 2019, 14:31 »
What does that mean? Does it have any consequences on the game?
« Last Edit: 16 Dec 2019, 14:33 by TheManInBoots »

Crimson Wizard

  • Local Moderator
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    • Lifetime Achievement Award Winner
    • Crimson Wizard worked on one or more games that won an AGS Award!
    •  
    • Crimson Wizard worked on one or more games that was nominated for an AGS Award!
Re: High resolution animation is causing huge lag and errors
« Reply #8 on: 17 Dec 2019, 10:56 »
There's one thing I don't remember exactly, but I think hardware accelerated graphics only works with power of 2 , square, sprite sizes on the low level. So 1600x900 would be 2048x2048 in the videocard.

AGS handles this, so there is no direct technical problem.

If I understand correctly, this does not have other consequences but occupying extra gfx card memory. So yeah, if you have larger sprites of non power 2 size, you will run out of gfx card memory somewhat faster too.

Ideally, engine could create texture atlases to reduce space waste, but oh well...


Just some math here: 1600x900x4 -> 5.7 MB per sprite
5.7 x 600 frames -> 3.5 GB the full animation.

eri0o, the compressed sprite file is 668MB big, uncompressed it's 2 GB big.

The sprites have different sizes, so not every sprite is 5,7 MB big, obviously.

The main point may be, when loaded in game sprites are uncompressed, so if you load all the animation at once it alone would take that much (2 GB, right?). Something to keep in mind.
Playing video file, on other hand, will keep only limited number of frames at once, so I believe it's worth to test video too.
« Last Edit: 17 Dec 2019, 11:04 by Crimson Wizard »

Re: High resolution animation is causing huge lag and errors
« Reply #9 on: 19 Dec 2019, 02:42 »
The main point may be, when loaded in game sprites are uncompressed, so if you load all the animation at once it alone would take that much (2 GB, right?). Something to keep in mind.
Playing video file, on other hand, will keep only limited number of frames at once, so I believe it's worth to test video too.

Yes, it's important to keep that in my mind.  I'm making first attempts on how to best convert the animation into video just in case.
However the issues I mentioned are still software related, and show up in a way less extreme way during game play as well (game slowed down etc., little "cracks" in the music). And since AGS offers the possibility for even bigger size templates (1920x1200) it remains quite useful to look into it as far as I can tell.

So here is the link to the animation project with the lagging animation:

https://drive.google.com/file/d/1tTeDxlTogBwmSCQ3csK1u5VNHg91njya/view?usp=sharing


Note:Make sure to delete line 611 in room script "room1.asc", I forgot to do that. It is a line from the original game and causes an error in the demo.


About the file:


It's 1,1 GB big, decompressed 3,16 GB.

The version used is: AGS 3.5.0.20 (Edit:RC4)




You can view more information about the script here

Spoiler: ShowHide

I created a quick overview of the different scenes as well to make it easier to understand the script if necessary:

https://i.imgur.com/9uvX9XX.png

I call the different scenes "pic" in my script, I guess I wasn't paying too much attention when choosing the term :P

So "Pic" 1-13 are static, 14-30 animated.

For the animation test I skipped 1-11 in the script, so as to test especially the animated part. I did not pre-load all the sprites, only some of them, so not all scenes/pics should be fluent.
You can check everything out in the room1.asc script.
Besides the room1.asc script I have coded only two functions in GlobalScript, the
Code: Adventure Game Studio
  1. function late_repeatedly_execute_always()
and
Code: Adventure Game Studio
  1. function late_repeatedly_execute_always()

The rest is all default game script.

Because of the lagging I did not end and perfect the animation. Some movements might be too slow or fast, the lighting bolt in scene/ pic 25 is misplaced, and I don't know about the last scenes because I never saw them in the Animation test project due to the error message. Music not perfectly placed etc.



Again, the problems that occur are as follows, ordered by importance:


1) The music is lagging while the sprites are loaded into cache. All game activities/loops seem to pause while a sprite is loaded into cache (the Loading symbol in the beginning of the game is a room background animation and should be moving as well).

2) I get an error message in the middle of the animation, even though my computer memory is not exhausted, as far as I can tell.

3) The loading into sprite cache takes a lot of time. When I skip the cutscene in the original game e.g. I have to wait an estimated two minutes before the game continues.


Good testing!
« Last Edit: 17 Jan 2020, 10:21 by TheManInBoots »

Re: High resolution animation is causing huge lag and errors
« Reply #10 on: 22 Dec 2019, 13:31 »
Btw, did anyone look into this? Does it lag just as much on other computers? Is there something that can be done about it? Or is it not so important an issue for now? I'm just wondering...
it's been several days without a reply...
« Last Edit: 22 Dec 2019, 14:05 by TheManInBoots »

Re: High resolution animation is causing huge lag and errors
« Reply #11 on: 22 Dec 2019, 14:09 »
several days -> 3 days just before Christmas. I started a discussion on the topic here github.com/adventuregamestudio/ags/issues/1009. This is important, it's just that other things are happening at the same time.

Crimson Wizard

  • Local Moderator
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    • Lifetime Achievement Award Winner
    • Crimson Wizard worked on one or more games that won an AGS Award!
    •  
    • Crimson Wizard worked on one or more games that was nominated for an AGS Award!
Re: High resolution animation is causing huge lag and errors
« Reply #12 on: 22 Dec 2019, 14:22 »
Btw, did anyone look into this? Does it lag just as much on other computers? Is there something that can be done about it? Or is it not so important an issue for now? I'm just wondering...
it's been several days without a reply...

It's impossible to solve this problem fast, a lot would have to be accounted for and changed in the engine to let it handle this properly, and there are other pending tasks already too.

At most we can test and find some temporary workaround.

TBH I have a number of things queued, which I try to prioritize now, and got busy irl too.


Also, why are there two threads about same problem? There was an original one, and we are discussing practically same things.

Re: High resolution animation is causing huge lag and errors
« Reply #13 on: 22 Dec 2019, 14:58 »
several days -> 3 days just before Christmas. This is important, it's just that other things are happening at the same time.

Alright, of course, and no problem at all. I just wanted to know.  :)


It's impossible to solve this problem fast, a lot would have to be accounted for and changed in the engine to let it handle this properly, and there are other pending tasks already too.

At most we can test and find some temporary workaround.

Also, why are there two threads about same problem? There was an original one, and we are discussing practically same things.

I did really not expect or ask for it to be solved fast, I just wanted to know if it was taken into account.

I started asking about the issue in the technical forum. The pre-loading of the sprites was really helpful what you told me, but it became obvious that there are certain limitations and bugs of the engine, the longer we discussed the issue.
And improvement on the engine is addressed in the engine development.
Also you mentioned yourself that I could propose in the engine development to improve texturing.

At the same time you seemed very busy and not to have a lot of time to look into this the time before I posted in engine development, so I reckoned maybe some other people in engine development have more time. I imagined it could be some work.

If it was a stupid idea, you can delete one of the threads, I really don't mind. I just wanted to bring up the issue, that's all.
« Last Edit: 22 Dec 2019, 16:06 by TheManInBoots »

Crimson Wizard

  • Local Moderator
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    • Lifetime Achievement Award Winner
    • Crimson Wizard worked on one or more games that won an AGS Award!
    •  
    • Crimson Wizard worked on one or more games that was nominated for an AGS Award!
Re: High resolution animation is causing huge lag and errors
« Reply #14 on: 22 Dec 2019, 21:47 »
it became obvious that there are certain limitations and bugs of the engine, the longer we discussed the issue.
And improvement on the engine is addressed in the engine development.
Also you mentioned yourself that I could propose in the engine development to improve texturing.

Right, sorry, of course it would've make sense to open such proposal, but it was not clear to me was kind of reply you were expecting.

To tell the truth, there are only few contributors to this project overall, and maybe like just a couple who actively work on the engine, so knowing the situation I doubt there will be much done about this before several months pass at least.

For now, guess I will be posting in original thread in case I learn anything about the test game.
« Last Edit: 23 Dec 2019, 00:10 by Crimson Wizard »