High resolution animation is causing huge lag and errors

Started by TheManInBoots, Sat 14/12/2019 23:24:22

Previous topic - Next topic

TheManInBoots

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.


eri0o

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


eri0o

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

Quote from: eri0o on Sun 15/12/2019 15:12:13
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.

TheManInBoots

#5
Quote from: eri0o on Sun 15/12/2019 08:58:12
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.

Quote from: eri0o on Sun 15/12/2019 15:12:13
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.
Quote from: Crimson Wizard on Sun 15/12/2019 15:18:45
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.

eri0o

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.

TheManInBoots

#7
What does that mean? Does it have any consequences on the game?

Crimson Wizard

#8
Quote from: eri0o on Mon 16/12/2019 14:20:04
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...


Quote from: TheManInBoots on Mon 16/12/2019 13:06:48
Quote from: eri0o on Sun 15/12/2019 08:58:12
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.

TheManInBoots

#9
Quote from: Crimson Wizard on Tue 17/12/2019 10:56:24
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

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: ags
function late_repeatedly_execute_always()

and
Code: ags
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.

[close]

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!

TheManInBoots

#10
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...

eri0o

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

Quote from: TheManInBoots on Sun 22/12/2019 13:31:37
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.

TheManInBoots

#13
Quote from: eri0o on Sun 22/12/2019 14:09:37
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.  :)

Quote from: Crimson Wizard on Sun 22/12/2019 14:22:32

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.

Crimson Wizard

#14
Quote from: TheManInBoots on Sun 22/12/2019 14:58:03it 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.

SMF spam blocked by CleanTalk