Can I improve high resolution animation that lags?

Started by TheManInBoots, Sun 17/11/2019 19:52:38

Previous topic - Next topic

TheManInBoots

No, it's fine Cassiebsg, it's a constructive idea.

Well, I created a new project only with the animation and it lags just as much.

I also tried to change a few things in the original project to use less sprite cache. For example by using a larger than screen sprite and then move it around, instead of having an animated object as the moving background frame by frame.
But now I am getting a new error message:


And also this one, which doesn't make a lot of sense to me:



And I get a similar error message as the first one in the dummy game I created with the animation as well:


And sometimes messages like the second one. It's a mess.


I am not a coder or programmer, I don't know how to fix the program...

I guess I send it to Crimson, in case he's gonna look into it...

I assume AGS simply isn't the engine to go to for high resolution games and animations.

Crimson Wizard

#21
Well, there are definitely boundaries of how much you can push it...
1280x720 games seem to play alright, but I never tried anything above that.

Certainly, I can look at this, now when 3.5.0 is released there's some spare time.

Crimson Wizard

#22
Erm, now reading your post (https://www.adventuregamestudio.co.uk/forums/index.php?topic=57632.0) and learning there's over 500 sprites in animation in 1600x900 res, I begin to question whether the idea of using sprite animation is a good one in the first place. It's just that you may get pretty high memory requirements with this if you push all that into cache at once.

Normally I think the solution here is to at least have a resource streaming in a separate thread, this is something that Nick Sonneveld is trying to add to AGS in his experimental branch.

So I really think playing video should be a better option in this case for now.


PS Regarding error messages, the second error is pretty obvious, it sais "Out of memory", which means your system ran out of memory trying to accomodate the game.
The first and the last error messages you show, maybe they happen because Gfx driver cannot create a texture of certain size. Or maybe it's because there's not enough memory again.
You said:
QuoteFor example by using a larger than screen sprite and then move it around, instead of having an animated object as the moving background frame by frame.
What is the largest sprite size in your game?

TheManInBoots

#23
Quote from: Crimson Wizard on Sun 15/12/2019 00:50:28
Erm, now reading your post (...) and learning there's over 500 sprites in animation in 1600x900 res, I begin to question whether the idea of using sprite animation is a good one in the first place. It's just that you may get pretty high memory requirements with this if you push all that into cache at once.

Actually not every sprite is sized 1600x900. Only the background frames, and certain animations where the entire background is animated.
Also, it is not my goal to load the entire animation into sprite cache at once.
The main problems that I believe to be related to the engine and think could be improved are these:

1) That the music and the rest of the game lags while the sprites are loaded into the sprite cache.

2) That I get an error message in the middle of the animation:
Shouldn't the old sprites be discarded from the sprite cache when new ones get loaded? So why do I receive an error message? There should be enough space to load new sprites into the cache when the old ones are discarded, right? I believe that's a malfunction of the program of some sort, isn't it?

Quote from: Crimson Wizard on Sun 15/12/2019 00:50:28
Normally I think the solution here is to at least have a resource streaming in a separate thread, this is something that Nick Sonneveld is trying to add to AGS in his experimental branch.

What is that resource streaming? Do I stream the sprites from a different thread?
Are you talking about Sonneveld's Adventure Game studio fork? (https://libraries.io/github/sonneveld/ags)
I wouldn't know how to use it. I have never used Visual Studio before. I'm not coding. Only basic AGS coding.

Quote from: Crimson Wizard on Sun 15/12/2019 00:50:28
What is the largest sprite size in your game?

Actually I changed the "larger than screen" sprite. It was 2081x900 big, but I split it into two sprites afterwards, so 1600x900 and 481x900. Hence the biggest sprite is 1600x900 big. But the error message remains.

So can I send you the animation project link once it's uploaded? Just to look into it?
I believe there are still things that can be improved about the program that are entirely unrelated to hardware demands. Like the lagging music for example.

Crimson Wizard

Quote from: TheManInBoots on Mon 16/12/2019 13:31:33
1) That the music and the rest of the game lags while the sprites are loaded into the sprite cache.

Music lag sounds strange if you have threaded audio enabled, I would like to see this in action and find out what's going on.

Quote from: TheManInBoots on Mon 16/12/2019 13:31:33
2) That I get an error message in the middle of the animation:
Shouldn't the old sprites be discarded from the sprite cache when new ones get loaded? So why do I receive an error message? There should be enough space to load new sprites into the cache when the old ones are discarded, right? I believe that's a malfunction of the program of some sort, isn't it?

It loads sprite cache as much as it's "max size" parameter allows. It discards only when it is filled up to "max size". What is your current cache size setting, and what is your system memory?
Note that program requires memory not only for these sprites, but for other things too: room backgrounds are kept separately, music, loaded scripts - these may not take much individually, but add some amount in combination.
Also, actually there's more - the sprite storage keeps "locked" sprites which are never discarded (I think this also counts DynamicSprite objects). You can press Ctrl+Alt+V in game to see how much is locked.


Quote from: TheManInBoots on Mon 16/12/2019 13:31:33
What is that resource streaming? Do I stream the sprites from a different thread?
No, not you, but the engine should do that itself.
Quote from: TheManInBoots on Mon 16/12/2019 13:31:33
Are you talking about Sonneveld's Adventure Game studio fork? (https://libraries.io/github/sonneveld/ags)
I wouldn't know how to use it. I have never used Visual Studio before. I'm not coding. Only basic AGS coding.
No, sorry, I am not suggesting to use it, I merely mentioned that there's a person who is experimenting with that right now, and we hope to have it in official version in the future.

Quote from: TheManInBoots on Mon 16/12/2019 13:31:33
So can I send you the animation project link once it's uploaded? Just to look into it?
I believe there are still things that can be improved about the program that are entirely unrelated to hardware demands. Like the lagging music for example.

Sure, I can take a look. I've got a decent internet connection so will be able to download big game too (so long as it's convenient for you to upload).

TheManInBoots

#25
Quote from: Crimson Wizard on Tue 17/12/2019 11:19:30
What is your current cache size setting, and what is your system memory?

My current sprite cache size is 1GB. I have a good deal more RAM, so I don't know why this happened.

Quote from: Crimson Wizard on Tue 17/12/2019 11:19:30
Sure, I can take a look.

So here is the link to the animation project with the lagging animation (I added it as well to the other thread for the developpers):

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.


Click below to view more file info
Spoiler

About the file:

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

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


About the script:

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, 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 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.

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


So hopefully it all made sense the way I explained it and I didn't forget anything, I'm a bit tired.
[close]

Good testing!

Crimson Wizard

#26
I will try to test this during the week.

But, could we please keep the discussion in this one thread? I was not sure why did you start another one in different forum section.

eri0o

In the project I have a crash here:

Code: ags
in "room1.asc", line 611

Error: SetCharacterView: invalid view number (You said 43, max is 6)


Top memory usage was 1.9GiB on my machine.

Spoiler

My pc config:
Code: bash
           .-/+oossssoo+/-.               eri0o@future
        `:+ssssssssssssssssss+:`           ------------------ 
      -+ssssssssssssssssssyyssss+-         OS: Ubuntu 18.04.3 LTS x86_64 
    .ossssssssssssssssssdMMMNysssso.       Host: MS-7924 1.0 
   /ssssssssssshdmmNNmmyNMMMMhssssss/      Kernel: 5.3.0-7625-generic 
  +ssssssssshmydMMMMMMMNddddyssssssss+     Uptime: 1 hour, 25 mins 
 /sssssssshNMMMyhhyyyyhmNMMMNhssssssss/    Packages: 2865 
.ssssssssdMMMNhsssssssssshNMMMdssssssss.   Shell: bash 4.4.20 
+sssshhhyNMMNyssssssssssssyNMMMysssssss+   Resolution: 2560x1440 
ossyNMMMNyMMhsssssssssssssshmmmhssssssso   DE: GNOME 3.28.4 
ossyNMMMNyMMhsssssssssssssshmmmhssssssso   WM: GNOME Shell 
+sssshhhyNMMNyssssssssssssyNMMMysssssss+   WM Theme: Adwaita 
.ssssssssdMMMNhsssssssssshNMMMdssssssss.   Theme: Pop-slim-dark [GTK2/3] 
 /sssssssshNMMMyhhyyyyhdNMMMNhssssssss/    Icons: Pop [GTK2/3] 
  +sssssssssdmydMMMMMMMMddddyssssssss+     Terminal: gnome-terminal 
   /ssssssssssshdmNNNNmyNMMMMhssssss/      CPU: Intel i5-4590 (4) @ 3.700GHz 
    .ossssssssssssssssssdMMMNysssso.       GPU: NVIDIA GeForce GTX 970 
      -+sssssssssssssssssyyyssss+-         Memory: 5619MiB / 24006MiB 
        `:+ssssssssssssssssss+:` 
            .-/+oossssoo+/-.                                       
[close]

Here is the game on my pc, not sure where the lagging parts are supposedly to be.

streamable.com/8jsm2

As CW said, this is not an easy to solve problem and will take time on multiple different areas in the Engine.

TheManInBoots

#28
So I'll answer you quick, before the holidays begin:

Quote from: Crimson Wizard on Sun 22/12/2019 14:26:38
But, could we please keep the discussion in this one thread?

Yes, no problem.

Quote from: eri0o on Sun 22/12/2019 14:56:17
In the project I have a crash here:

Code: ags
in "room1.asc", line 611

Error: SetCharacterView: invalid view number (You said 43, max is 6)


Yes, you're absolutely right. Thanks for pointing that out. It is set to the view number in the original game, and I could not notice because the animation always crashed before I reached the end. I will note that in my comment above.

Quote from: eri0o on Sun 22/12/2019 14:56:17
Here is the game on my pc, not sure where the lagging parts are supposedly to be.

I watched your video, and the animation is being played flawlessly! And the music playback? There was no problem with it?

I have 3.84 GB usable RAM, and 2.2 GHz CPU. Shouldn't that be working as well?

So is my computer simply to slow to perform the animation?
Or is it because you use Ubuntu?
Or is it mainly the graphics card maybe?

My graphic card is called "Mobile Intel(R) 4 Series Express Chipset Family".
And I see now that it has 1,76 GB usable memory, maybe that is the memory that is relevant for the game!? And not at all the computer memory?
So if it has to use 1,9GB as you said, but has only 1,7 GB available, maybe that is when the game starts to really lag???

On my PC the animation starts lagging for example right in the beginning during the scene with the three flying marbles in front of the island and water (scene 14). Those sprites are not pre-loaded and during the animation the music is constantly interrupting and the animation goes about very slowly.
Also on scene 17, with the big moon, it lags a lot. And then there is the error message. See:

https://streamable.com/pl296

(Sorry for the terrible audio, maybe make sure to lower the volume beforehand. I wasn't aware it was recording with the computer inbuilt mike, but you get an idea on how it lags)

Quote from: eri0o on Sun 22/12/2019 14:56:17
As CW said, this is not an easy to solve problem and will take time on multiple different areas in the Engine.

Yes, I am aware, and I am not expecting any fast results. I am turning the animation into a video for now. I use "Synfig" as a software, which is quite easy to use and is perfect for this job. The animation might look even better after that!

Quote from: Crimson Wizard on Sat 07/12/2019 16:10:48Engine does not do anything that could lead to this. The only explanation that I have is that maybe operating system keeps some of the loaded data in its own cache and this allows for faster inserting them back into engine memory when it asks to load files from disk. I heard Windows actually may do that with larger apps so it's faster to start them up later.

Crimson Wizard, actually I can confirm your theory. I was editing the sprites in another software, "Synfig", to prepare them to turn them into video, and then when I opened AGS and played the animation for the first time, the animation was played fluently, as if the sprites were already pre-loaded, even though they were not! I basically pre-loaded them in a different program lol! That's the same reason why they were "pre-loaded" by previous game launches.
However I tend to believe that they are not necessarily saved in the working memory of the computer, but actually in the memory of the graphic card. I think that would make total sense, don't you?

Quote from: Cassiebsg on Fri 06/12/2019 17:15:43
You can see the plugin in action on this game (...)
Or my own game in the intro and start movie/cutscene

Cassiebsg I actually wanted to ask you about the intro: those text titles are really smooth! Were they part of the video or did you add them with AGS?



Alright, and enjoy the holidays I guess

eri0o

I had no problem with the audio. I am sorry I couldn't record it, I screwed something in OBSStudio and forgot how to switch back to internal audio output. I have no answers for your questions on where the bottleneck is.

TheManInBoots


Cassiebsg

The text is not part of the video.
The video only has image, no sound or text on it. Reason for it is, that you can change the music tracks that are playing in the settings if you like, and text I also wanted it to be changeable in case of needing it to be translated.
The text is being displayed using CW's great Typewriter module.  (nod)
There are those who believe that life here began out there...

TheManInBoots

#32
Cool. Umm, Crimson's Struct Stream? I saw Phemar created a type writer module which seems pretty cool.

Since the problem is related to bottlenecks in hardware and PC performance it would be pretty cool to have an option in the future to change the quality of your game (Low, high resolution), so that you can create a high resolution game that can be played on all computers. Also interesting to find out where the bottlenecks are exactly. Would be cool if the engine could instead of displaying error "not enough memory", it could display "Your Computer performance is not high enough.(or your graphic card is not compatible) Want to switch to lower quality?"

I might suggest that to developmnt at some point.

HEre's a summary of gthe thread for lazy people who deaL with high resolution lagging:


SUMMARY AVOID LAG

Spoiler

To avoid lag in high resolution animations you can pre-load sprites. This is useful for in-game animations.
Fastest and easiest way is Mouse.ChangModeGraphic, e.g. sprites 1-100

Code: ags

int sp=1;

while (sp>0&&sp<101)
{Mouse.ChangeModeGraphic(sp, eModeUsermode2);
sp  ;}


You can also play videos as the animation. This is useful for cutscenes.
Personally I used Synfig and a video editor to turn the animation into a video.

Side note: There is a plugin that allows you to play videos in the background, so that you can play music, audio at the same time, and place, text, objects, characters, etc. on top of the video. For Windows only

[close]

Thnkas

Crimson Wizard

#33
Quote from: Cassiebsg on Mon 23/12/2019 09:34:01
The text is being displayed using CW's great Typewriter module.  (nod)
Quote from: TheManInBoots on Sat 28/12/2019 17:43:31
Cool. Umm, Crimson's Struct Stream? I saw Phemar created a type writer module which seems pretty cool.

I made a more universal module later, because Phemar's is only blocking (IIRC) and I needed an non-blocking one for my game, with more ways to customize it.
It's called Typed Text: https://www.adventuregamestudio.co.uk/forums/index.php?topic=54450.0

I am aware that the description is not as clear as one would like to... I still plan on creating a proper documentation with less abstract explanation.
But it comes with a demo game, so hopefully may give a better idea of its use.

TheManInBoots

#34
Demo games always help. I'll check it out thank you

Btw. The links didn't work for me I had to change the ending to download it, e.g.  "... ags-script-modules.git" to "... ags-script-modules/downloads/" maybe that's just my PC

Crimson Wizard

Quote from: TheManInBoots on Thu 02/01/2020 20:39:10
Btw. The links didn't work for me I had to change the ending to download it, e.g.  "... ags-script-modules.git" to "... ags-script-modules/downloads/" maybe that's just my PC

There are two links: first, with big "DOWNLOAD" point to zip archive, and another - "git cloning address" is to be used with "Git" source version control tool.

On a side note, I seem to finally able to get most of planned tasks off my hands, so hopefully will be checking your demo game soon too.

TheManInBoots

#36
Quote from: Crimson Wizard on Thu 02/01/2020 22:45:21
Quote from: TheManInBoots on Thu 02/01/2020 20:39:10
Btw. The links didn't work for me I had to change the ending to download it, e.g.  "... ags-script-modules.git" to "... ags-script-modules/downloads/" maybe that's just my PC
There are two links: first, with big "DOWNLOAD" point to zip archive, and another - "git cloning address" is to be used with "Git" source version control tool.

Makes sense, thanks for the explanation

Quote from: Crimson Wizard on Thu 02/01/2020 22:45:21
On a side note, I seem to finally able to get most of planned tasks off my hands, so hopefully will be checking your demo game soon too.

So the question for you is then how worthwhile it is to look into making the way animation is handled more efficient. eri0o already tested it and it works fine on his PC, so the lagging comes also from lower PC performance. You have the overview of what you're working on, so you know what's important for the game development.

Crimson Wizard

#37
Alright, finally to the animation demo.

Firstly, the issues I found when started:
- it takes too much time to startup the game. There's no "preload" screen in this game, and it looks like game window froze, because there's no image for around 5 seconds.
- the animation itself and music works okay, for the first time
- somewhere around the room with the sea and some coastal rocks game crashes with "out of memory" error. Same happens if I try to skip the intro.
Now, I did not think about this earlier, but thing is, the engine is built as a 32-bit program, which supposedly means the max memory it may use is 4 GB. But this game crashes with "out of memory" when it reaches 2 GB. NOTE: I have 16 GB RAM on my PC.
Okay, 64-bit Windows may be limiting 32-bit programs to 2 GB actually: https://www.quora.com/What-are-the-memory-limits-for-32-bit-applications-on-a-64-bit-Windows
- skipping intro does not really skip it, it seem to keep playing script on background for the same time.
EDIT: - There's a peculiar issue of sprite cache reporting "locked size" = 1.5 GB. You can see it if you stop intro mid-way somewhere before it crashes and press Ctrl+V.
This "locked size" are special images that are never automatically deleted by the cache. Meaning there's only 0.5 GB left for the rest of sprites... Might be a good idea to understand why it locks so much.
I remember that mouse cursor images are getting locked, and DynamicSprites are. Since you are using that ChangeModeGraphic trick to preload sprites, I wonder, if AGS has a bug and does not release previous sprites set as a cursor..... UPDATE but after I commented out all ChangeModeGraphic calls, that reduced "locked size" only to 1.35 GB.....



One thing I can tell about animation itself... it struck me that I do not see much of things animated on screen at the same time, so at first thought the situation is not too bad.
But when I looked into game project I found out that part of the animation is created in a very non-optimal way.

Take the first scene, for instance. There is a static image of a boy, and only his eyes are flashing. Normally, one would create 2 tiny objects as flashes and animate these, but instead in this game you have five 1600x900 full-screen sprites which has nothing but these tiny flashes in the middle. These could be easily reduced to like 16x16 sprites put onto 2 objects in the room, making this part of animation take about 100 times less memory already.

Other quick examples that I noticed:
* the "Press escape to skip intro" looks like basically one image rescaled several times to make an animation. This could be optimized by having 1 image and scaling the room object. Or have a TTF font or sprite font and drawing a text.
* the marble with a face and wings - these sprites are bigger than necessary and could be cropped to reduce to around twice as smaller size. In fact, if you push to max effect, you could place the face, that does not change at all, onto the 1 separate sprite and object, and animate wings on 2 separate objects. This would reduce memory for these flying faces more roughly by 1/3.
* the "monster attack" animation I found in the sprite folders - again, the sprites are 1600x900 big but contain too little, these could be cropped significantly and played while also moving object around.

It's important to note that making animation with game objects is not the same as making animation in a video. Video may have good animation compressions by only remembering the differences between series of frames, but when you play separate frames by hand in AGS you cannot do that, because AGS does not know how are you planning to use these sprites, so there's much less potential for automatic optimization. So, when you are doing big hires animations like this by hand (using game objects), you have to optimize yourself.

TheManInBoots

#38
Heya

Saw your post only recently.

Quote from: Crimson Wizard on Sat 11/01/2020 16:32:28
it takes too much time to startup the game. There's no "preload" screen in this game, and it looks like game window froze

I can see the Loading symbol when I run the game on my computer, so that probably means that your computer pre-loads the sprites fast enough so that you don't even get to see the Loading symbol.

For me, too, it takes too much time starting the game with a blank, black screen (in the "room before fade in" phase).
Also, as a side note: When I start a project and create a high resolution animation with less sprites, only a bunch of them, it works without any problem. However from a certain number of sprites this terrible lag and the error message is happening. Relating to what you said
Quote from: Crimson Wizard on Sat 11/01/2020 16:32:28
There's a peculiar issue of sprite cache reporting "locked size" = 1.5 GB.
my theory is that the software does actually -before the room is loaded- lock a certain number of normal sprites only used in animation into cache, which would be badly programmed. So when I have a few sprites in the animation and thus only a few sprites in locked cache it does not interfere because it's nowhere near 2 GB.
So it seems the "Locking" into cache is not very clean and accurate when choosing which sprites to lock.

Quote from: Crimson Wizard on Sat 11/01/2020 16:32:28
NOTE: I have 16 GB RAM on my PC.
Okay, 64-bit Windows may be limiting 32-bit programs to 2 GB actually:

So I assumed right after all, that it's not directly related to RAM but also related to engine. I'm glad it's not just my PC. Is your Graphic Card Memory anywhere near 2 GB?
Does it make any difference when you change the Sprite cache in Settings to 2 GB? (Because the demo is set to 1GB as is)

I mean after all that is a great insight you have! So if at any point this problem is addressed in development, you already know that the core problem is in how the sprites are selected and filtered to get locked into the sprite cache.

Quote from: Crimson Wizard on Sat 11/01/2020 16:32:28
You can see it if you stop intro mid-way somewhere before it crashes and press Ctrl+V.
Quote from: Crimson Wizard on Tue 17/12/2019 11:19:30
You can press Ctrl+Alt+V in game to see how much is locked.

Sorry, what do you mean by "stop" the intro? Press escape? Close the game? I was not able to view the Locked Sprite info, no matter at what point.
Neither by pressing "Ctrl+V", nor by pressing "Ctrl+Alt+V".

Quote from: Crimson Wizard on Sat 11/01/2020 16:32:28
UPDATE but after I commented out all ChangeModeGraphic calls, that reduced "locked size" only to 1.35 GB.....
That again shows how "unclean" and inaccurate the selection process for sprites is. I pre-loaded the biggest part of the animation. The sprite file is almost 700 MB big.
So under no condition should the locked Sprite size be reduced by only 150 MB. It should be either ALL the pre-loaded sprites that get locked, because Mouse Cursor Graphics are locked, or NONE that get locked. But it's neither of those two options, it seems that only SOME of the pre-loaded sprites get locked.

Quote from: Crimson Wizard on Sat 11/01/2020 16:32:28
Normally, one would create 2 tiny objects as flashes and animate these, but instead in this game you have five 1600x900 full-screen sprites which has nothing but these tiny flashes in the middle. These could be easily reduced to like 16x16 sprites put onto 2 objects in the room, making this part of animation take about 100 times less memory already.

Well, images usually only take up a lot of space when they include a LOT of different colors and textures, such as exactly the photographs I use that are vividly colored. But plain, one-colored sprites (or plainly transparent sprites) do not actually take up a lot of space. One transparent sprite, sized 1600x900, takes up more or less 55-60Kb. So by reducing the sprite size I would save only 50-55 KB in this example (55x6sprites=330KB). That is next to nothing when I have to reduce 1 GB or 1000000 KB sprite cache. And working through the entire animation to try to save space like that is just a waste of time. I really pushed myself to the limits doing this animation, I haven't really done a lot of animation before, so I already got exhausted creating this. On top of that I want the sparkle in the eyes to be placed exactly where it feels right to me. So I have to go to my graphics program, make the size smaller, than measure exactly the difference to the full sized image for the smaller sprites for both x and y, and transfer those Coordinates to AGS. Now imagine I do that for every object in the entire animation. It's a lot of work and it has very insufficient results. Whereas when I animate in full size I can simply set x,y to 0,900 and it's perfectly placed, and I added only 55KB to Sprite cache.

Quote from: Crimson Wizard on Sat 11/01/2020 16:32:28
the marble with a face and wings - these sprites are bigger than necessary and could be cropped to reduce to around twice as smaller size. In fact, if you push to max effect, you could place the face, that does not change at all, onto the 1 separate sprite and object, and animate wings on 2 separate objects. This would reduce memory for these flying faces more roughly by 1/3.

Yeah I could have done the separating between wings and face to save space. However I am reluctant to reduce the quality and size them down somehow...:P

Quote from: Crimson Wizard on Sat 11/01/2020 16:32:28
the "monster attack" animation I found in the sprite folders - again, the sprites are 1600x900 big but contain too little, these could be cropped significantly and played while also moving object around.
I cannot just move the sprite to make it look like he jumps. The monster is rotating while he jumps, which makes things more complicated again since rotating is not developped and integrated in AGS yet. Also it would be really messy to make it look like he catches the flying marble perfectly and align two different sprites perfectly. I would set approximate coordinates, run a terribly lagging animation, estimate new coordinates again, run a terribly lagging animation again, estimate new coordinates again... That's just too much. And again same thing:  I would save only very little space with a lot of work.

Quote from: Crimson Wizard on Sat 11/01/2020 16:32:28
the "Press escape to skip intro" looks like basically one image rescaled several times to make an animation. This could be optimized by having 1 image and scaling the room object. Or have a TTF font or sprite font and drawing a text.
Yes I could have done that with Scaling and saved some sprites, true. I'm not gonna use that symbol eventually anyway. Can you scale Sprite font texts? For now I'm having difficulties with your type writer, seems a bit complex to me on the first attempts. I will still experiment a little bit more with it...

At least now you know that there are issues concerning the locking of sprites that can be adressed to improve the engine. The lagging music seems to be only my PC when it has to perform too much, so nothing engine related at all. I had the same problem to a lesser degree with a different game that wasn't AGS related. But that genius insight you had with the sprite locking, and the error message you get on your PC as well, that's AGS.
I for one will continue making the animations as videos. It's easier, it has way better performance, and I don't get all of those problems, which freaked me out a little bit at one point to be honest.

It's maybe not the worst suggestion to make the sprites all as small as possible where you can. But as I said it's just sooo messy and so much trouble doing that with AGS that it's barely worth it.
However that gave me an idea for a very useful option in the room editor that would make it all extremely easy, and I feel like anyone who has worked on a more elaborate animation so far could agree on it's utility:



Spoiler

An option to actually preview an object or character on a specific sprite in the room editor, and an option to preview it with scaling!
This way you can view a character in the view that you use in the animation, with the scaling that you use in the animation, move it exactly to the spot you want. And then you simply copy their x,y-Coordinates and use them in script of the animation, super easy!

I made some illustrations just for how that would look like, to make this clearer.
Those are only illustrations, obviously:




View in High Resolution: https://i.imgur.com/Xy29pto.png

So you can click the button in order to preview the character (or object- I will say only character from now on, only because I am too lazy to mention object as well every time) with a specific sprite that you choose, and if you click again you deactivate the preview.



View in High Resolution https://i.imgur.com/sNw8dZQ.png

So when you click on the little loading box on the side you can choose what Sprite you want the character to be previewed as. You can either type the sprite number or browse:


And then you can activate or deactivate the preview, while seeing on the button what Sprite you can preview as:




And for the scaling one could add a tick box, simply like this:



View in High Resolution: https://i.imgur.com/azU3JDu.png



View in High Resolution: https://i.imgur.com/qOaNtXw.png

And then you could choose the Scaling value for preview, by clicking on the small loading box on the side next to it. There you have the option to have a specific Scaling value, or preview the character with the scaling of the walkable area at it's x,y Coordinate:



Just to be clear, this wouldn't have ANY effect on the game play itself, it would only change the preview in the EDITOR while the button is clicked or the box is ticked.
This would really help organize and structure animations in an intuitive, effective way. You will know exactly where your characters and objects have to go during animation, you can accurately estimate the whole process of the animation. I know you guys are all geniuses when it comes to programming and logical problems, way better than me. But I think that part of creating games is also the story-telling, the creation of a world, being very IMAGINATIVE. And for that I think an intuitive tool like that can help tremendously make game creation and animation a bit more intuitive and imaginative, and will result in slightly better games.
What do you think Crimson, or anybody for that matter?
[close]

I got this idea here while working with this animation, but maybe I should post this in Editor development

Edit: And sorry, just saw how long this reply became. I just wrote off the top of my head, you can answer when you get to it, no pressure :)

Crimson Wizard

#39
I do not have time to answer everything, but will note coupe of important things now.

1. How did I stop animation in a middle to press Ctrl+Alt+V and check the cache size.

Simply put "return;" command in the middle of the intro function to skip rest of animation before it crashes. When it stops, I can press buttons , and so on.


2. About locked sprites.

First of all, I must clarify sprite cache mechanics here.

Sprite cache consists of 2 types of sprites, let's call them cached and locked.

Cached sprites are loaded when necessary, but may be unloaded if there's a need to load more sprites, and cache is full. This is how most of the regular sprites work in AGS.

Locked sprites are forbidden from unloading until explicit command. Only following sprites are locked:
* Mouse cursors and cursor views (views set for cursor animation). Because cursor is always on screen, and should be persistent.
* Very first player's view. I think this is something existing for historical reasons, to speed things up for all the game's duration, although today games need other ways to optimize sprites.
* Dynamic Sprites. These cannot be released until game author tell so by calling DynamicSprite.Delete(), obviously.

So, I thought it is not normal that your game has a lot of locked sprites, because it's not normally supposed to be like that. The sprites you preload were supposed to be registered as regular "cached" sprites, at least that was my original thought.
Indeed, Mouse.ChangeGraphic locks the sprite, but I made a guess it unlocks the previous one, making it regular cached sprite that may be later disposed automatically if run out of cache space......


3. The real problem.

Thing is... it does not seem to unlock locked sprites after calling Mouse.ChangeGraphic again. Which is ridiculous, but true. Maybe it was never much of a problem, since cursor gfx are usually small enough. I could miss something, but from what I've seen in the engine code, it looks like it never actually releases any of the locked sprites. So, this might be a bug number one.

This essentially means that you cannot use Mouse.ChangeGraphic as it is now, because with every use you will reduce amount of available cache size, irreversibly.

I also found another bug, related to locked size counter, apparently it keeps increasing it if the locked sprite is told to be locked again, which means that this statistic is unreliable currently.


Finally, regarding the big locked amount, which exists even if I remove all the calls to Mouse.ChangeGraphic. Remember what I said, about the first player's view being locked?
Well, in your game player character is "cm", and its original view is View 1, which is a HUGE view with many big sprites. All of these get locked irreversibly as well, taking up cache space for little good reason. This also explains why the game takes so long to start....


Because some of the above are bugs (with a high level of certaincy), I will be looking to fix these, and see if that changes anything in regards to your game.
Most of this is a very old behavior from late 90-ies, when games were small so all that could sound like a good idea... Guess no one have looked into adjusting this before.



UPDATE:

So here's an experimental engine build that does not lock sprites at all, and only caches them (so that they could be replaced later along the game):
https://www.dropbox.com/s/6wq629989wpj3qg/acwin-3.5.0-test-nospritelocks.zip?dl=0

I also removed obligatory player's view precaching. That made game startup almost instant for me.
This is of course not the final solution, only something to test. I wonder if it will make any difference for you.

SMF spam blocked by CleanTalk