Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Crimson Wizard

#3041
There have been some improvement to Overlays in 3.6.0, and generally improvement to perfomance of GUI and overlays since 3.5.1, I've been also looking for other opportunities to make Overlays more useful in the long run at a low effort cost (since 3.6.0 is in Beta, I would not want to do any serious code rewrite in this version). There are couple of ideas that technically should not be difficult to implement, but would require some good solution script-wise. Even if these won't get into 3.6.0, this still would be interesting to discuss.

These ideas are:
1) Overlays without sprite copy, but with a sprite reference;
2) Room Overlays.




1. Overlays with a sprite reference

Right now Overlays work with a full sprite copy. I guess this may be because they were first created as textual objects, and later expanded to also have sprite on them.
This makes it easier to create textual overlays, as you just have to pass a string into Overlay.CreateTextual. This also makes it somewhat easier to create graphical ones with Dynamic Sprites, as you don't have to keep that sprite anymore: as soon as overlay is created - it has a sprite's copy, and dynamic sprite may be disposed. Unlike that, if you're using dynamic sprites as object graphic or view frame, you must keep that sprite in a global variable at all times, otherwise the object will loose its graphic (in the past it also crashed the game, but not anymore: now it simply resets it to sprite 0, for safety).

Unfortunately, such approach backfires when you are reusing the sprite on several objects, in other words - either a) displaying same sprite often, and especially if b) using multiple overlays to display a larger numbers of identical images. Overlay itself is a simple struct, but each time when created it also copies the sprite. That makes its creation slower, and increases the overall memory use. In fact, it also increases the disk space needed for a save, as all overlays must write their bitmaps into the save file; which is quite silly if you used a regular sprite from the game resources to create them.
This is even more sad as overlays today are the only object in AGS that may be created at runtime in script. On one hand you may use it to generate graphic scenes on the fly, on another - it is not as optimized as it could be.

There's another consideration here. As you might know, AGS uses "sprite cache", that is - it caches often used sprites in memory to keep them ready and not load/allocate over and over again. Unfortunately, it does not do the same to textures when running Direct3D or OpenGL renderers. That is a general issue, and rather annoying one, as it makes these renderers actually somewhat slower* and more memory consuming than they could be (*slower in one thing, but thankfully they still balance this with being faster in others). I think that one of the future improvements (and quite overdue) is to also cache the textures prepared for particular sprites. If that's done, then whenever you assign a sprite repeatedly, not just the sprite won't be reloaded, but also the texture won't be recreated but taken from the cache instead and shared between multiple objects.

But even if that's done, with overlays things would remain the same, so long as it's function is based on a sprite copy.

So, what is that script problem in this situation? Technically there's little issue: just don't make a image copy and add a sprite reference instead.
But if this is done, that would change the known overlay's behavior, where user may paste a dynamic sprite over it, and discard the sprite object. Instead they would have to make global variables for these sprites and keep a record on them, deleting these when no longer necessary, etc.
Perhaps this is also a problem with the dynamic sprite management in AGS, as their references are not contained in some storage where they will be "safe" from occasional loss, but must be referenced by a script variable.

EDIT: Another difference between having a sprite's copy and a reference is that you may continue editing same sprite after assigning it to a game object. If an object has sprite's copy - then it won't receive further changes. If it has a reference - then it will be automatically updated as soon as you finish editing the sprite (call to DrawingSurface.Release()). /EDIT

What could be a solution here script-wise, if we would like to allow Overlays with a sprite reference instead of a copy? Should there be a new function, that explicitly sais that it's not copying the sprite? Or, on contrary, a function that sais that it makes a copy, while CreateGraphical would make a reference? Are there any alternate ideas maybe?

In regards to dynamic sprites, that may be a separate question (or is it?), but one idea is to treat their assignment to an object as a proper counted reference, thus making them not automatically disposed while their number is assigned to at least one game object.




2. Room Overlays

IMHO this is a interesting idea. Overlays are unlimited (since 3.6.0), easy to make in script, but they are always on top of the room. They received ZOrder property in 3.6.0, so now may be freely sorted among GUI.
In my opinion, it's technically not hard to allow have them inside the room, where they sorted among the room elements (objects, characters and walk-behinds). This opens very good opportunities for setting up temporary visual effects inside the room, as well as generate room scenes in script. Especially since other objects are fixed, and cannot be created or deleted at runtime right now (that would require significant change to how AGS is designed, and is a separate big topic).

But the question that I have is again, how to organize this in script to make convenient? Having a boolean argument in CreateGraphical / CreateTextual is simple, but may be annoying. It may be an enum, which means "game layer" or something (like, eRoomLayer, eGUILayer). Alternatively, these might be separate pair of functions, e.g. Overlay.CreateRoomTextual and Overlay.CreateRoomGraphical.

What do you think?
#3042
As of AGS 3.6.0 Overlays are the only graphical object in game that:
- unlimited in numbers;
- may be freely created and deleted in script;
- has a sprite on it.

Other objects (gui, characters, etc) are only created at design-time; room objects are also limited in number.

This makes Overlay useful for creating temporary custom objects that do not have any additional behaviors, a simple "sprite" object on screen.
Since you know Overlay's position and size, you may also script trivial hit detection (simulate clicking on overlay), collision, and anything else. Hence it also may serve as a base to script a custom game entity from ground up.

Overlays currently have two downsides:
* it contains the sprite's copy, not reference (as with everything else); this is the biggest issue with overlays today imo, as this increases the memory requirement when having hungreds of them at the same time. (this problem may be solved in the future, with some changes to how overlay works)
* no pixel-perfect detection, but I think that's rather a limitaton of script that does not let test a picture at certain coordinates, or test two pictures for collision with just one command.

Quote from: abstauber on Mon 18/04/2022 20:58:06
I still haven't fully understand the performance gain using overlays instead of drawing everything directly to a surface.

Any graphical object in AGS is processed by the graphics card when drawn, which means that when it does not change the sprite itself, but moves, scales * or changes graphic effect (transparency, tint) there's no additional processing on CPU, everything is handled by GPU, thus the game perfomance suffers least.
Also, these objects are z-sorted automatically, and rather fast too. With raw drawing you not only have to sort the drawn sprites yourself, but you have to redraw everything behind each moving sprite each time it changes position.

* - rotates too, and doing any other shape changes; but these are not supported in the current version yet.

In other words, if you have something that has a fixed sprite, or does not change too often, but often moves, scales (resizes), changes transparency, etc; requires distance sorting and may overlay other objects or background - then using a game object will be many times faster than raw drawing.

This does not exactly mean that you should use objects (or overlays in particular) everywhere. In case of doubt every option should be tested and compared for speed.
Raw drawing works fine when there's no image transformation and not alot of movement of elements around the surface. Also, in case of tiles, drawing 100 tiles on a larger surface may actually be faster than creating 100 overlays. (given how overlays work currently, that would also take less memory perhaps)

On the other hand, the difference in speed may be negligible in low-res games with small amount of objects. The higher sprite resolution is, and the more objects are there, the more difference is between using objects and raw drawing.
#3043
Quote from: abstauber on Mon 18/04/2022 19:58:02
And is there a particular thread discussing the new possibilities with overlays?

There's not that much to mention, this is a relevant part of the change list (you may find it in the 3.6.0 release thread):
Quote
- Added Overlay.Width and Height properties, that let you freely scale existing Overlay.
- Added readonly Overlay.GraphicWidth and GraphicHeight properties that let read original overlay's graphic size (for textual overlays too).
- Added Overlay.Transparency property.
- Added Overlay.ZOrder property that lets you sort Overlays on screen among themselves and GUI.

EDIT: oh right, and also quite important
Quote- Removed Overlay limit.

So basically overlays at the moment are the only graphical object in game that a) is not limited b) may be created and deleted in script.
#3044
Hello, please check the sticky topics in this forum section, there's a topic per each available engine port:
https://www.adventuregamestudio.co.uk/forums/index.php?board=17.0
#3045
Quote from: Pajama Sam on Mon 18/04/2022 16:27:41
But why is it faster loading in a game with imported tiff files?I know it's changed to sprites but why is it faster even though its changed? Could it be because of a different way of displaying colors?I've gone through a few tests in my game and it seems much faster with imported tiff files. ???

We won't be able to answer this question without knowing full details about your game resolution and color depth, and measurements of sprites and parameters of the sprite import.

But, as eri0o mentioned, there may be various factors why the game may work faster or slower, so it all depends on how do you measure the perfomance.
#3046
Overlays happened to be the most useful kind of object in todays AGS when you need a large number of moving and transformed (scaled etc) sprites on screen.
* overlays are designed unlimited (limited only by the program memory)
* they are rendered as a texture and thus accelerated by the graphics card (if you run with Direct3D / OpenGL render).
* it's a tiny structure without any superfluous properties that may screw logic up if not taken care of.

Before 3.6.0 room objects and characters could be more performant, as overlays did not support scaling for some reason, but since 3.6.0 beta Overlays may be scaled too
(https://www.adventuregamestudio.co.uk/forums/index.php?topic=59842.msg636645302#msg636645302)

PS. There's currently a serious issue remaining with overlays that they don't share a sprite reference, but make a bitmap copy; i believe this should be taken care of in the future.
#3047
Quote from: abstauber on Sun 17/04/2022 22:39:53
Code: ags

An exception 0xC0000094 occurred in ACWIN.EXE at EIP = 0x0050A95E; program pointer is +373, ACI version 3.6.0.23, gtags (663,20)



So, this happens when any gui control has width or height = 0.
There's a temp fixed build here (installer and archive):
https://cirrus-ci.com/task/4575886656667648
#3048
As far as I know, TIF and TIFF is just the same thing, so it's a matter of adding new extension to a file filter.
#3049
Quote from: abstauber on Sun 17/04/2022 23:40:52
I've just PM'ed the link to the project. It could also be very possible that I did something stupid, as I haven't spent much time porting the code yet.

The above is not a scripting mistake, but a engine error. Program should not crash like that even if script is wrong.

Quote from: abstauber on Sun 17/04/2022 23:40:52
Oh and the keyboard controls seem to be different now too. At least the arrow keys don't work anymore.

If the "General Settings -> Backwards Compatibility -> Use old-style key handling" is set to true, then nothing should change; so there may be a engine bug too.
#3050
Quote from: abstauber on Sun 17/04/2022 22:39:53
Code: ags

An exception 0xC0000094 occurred in ACWIN.EXE at EIP = 0x0050A95E; program pointer is +373, ACI version 3.6.0.23, gtags (663,20)


0xC0000094 is "division by zero". "program pointer is +373" is around the gui controls drawing. I think "gtags" should contain ID.

Does it still crash? If yes, may I have a compiled game for a test?

EDIT: Hmm, the only suspicious division i could find is in Slider, when MaxValue - MinValue = 0
#3051
Quote from: Pajama Sam on Sun 17/04/2022 03:35:55
Not that I like to harp on this but do you think you might soon allow dragging folders in the sprite menu?

Do you mean dragging around the list, or drag & drop whole folders from the file explorer to import sprites?
#3052
Engine Development / Re: Why is AGS slow?
Sat 16/04/2022 23:39:34
Quote from: eri0o on Sat 16/04/2022 23:28:20
About template, I mean like evolving from the issue you describe, it's the last proposition you present in your list, on the top post.

Hmm, if you are refering to the paragraphs starting with "An example of a very straightforward solution for type safety could be helper function template, where implementations would deduce a type and pass it further to actual registration."
That was merely a suggestion for registration helpers. It was supposed to be on top of the actual system, and its only purpose is type safety, not changing anything in how it works.

Quote from: eri0o on Sat 16/04/2022 23:28:20
About fuzzie port, you meant the interface here: https://github.com/adventuregamestudio/scummvm/blob/ags/engines/ags/scripting/character.cpp#L2130-L2142 ?

We have a similar interface, but the difference is that she also passes the function type along. In her variant this type is defined as a string "i", "iii" and so on.
But looking at the how this solution works again now, she does not have a switch, which I thought about for some reason. In fact, she came to an opposite variant, where the api functions actually are like our "wrapper" functions. E.g. like this.

This is an alternate approach, which I forgot to mention in the ticket for some reason. It's to instead have this kind of function type exposed to plugin API, and make plugins work with it instead of calling functions of potentially unknown prototype.

The consequence of such approach is:
* any previously existing plugins which use script functions will no longer work;
* plugins will likely have to pack parameters in an array in order to pass them into this function (extra work for them).
* a big "cleanup" work which would replace calls to "real functions" in wrappers with a working code itself, similar to how it's done in fuzzie's port.
I might add this information into the ticket later.
#3053
Engine Development / Re: Why is AGS slow?
Sat 16/04/2022 23:18:59
Quote from: eri0o on Sat 16/04/2022 22:51:11
Quotehttps://github.com/adventuregamestudio/ags/issues/1223

I still doesn't understand which type of solution for that you would find acceptable. Like the template approach you mention, would it be accepted?

I can't tell which "template approach" are you refering to?
Personally I wanted to try the switch method described in the ticket, similar to what fuzzie did in her scummvm port. It may be not hard to make a minimal version with only few registered functions and test for correctness and any perfomance changes.
From the function-registration side this approach requires functions to register along with the "type description" that notes the number and types of parameters, and type of return value. This description may then even be made available through the plugin interface.

Quote from: eri0o on Sat 16/04/2022 22:51:11
Or are you looking into the reverse, like the Lua FFI interface (https://luajit.org/ext_ffi.html), which would register C functions to the AGS Script interface, and then it's mostly about exporting the AGS Engine API as C functions.

I don't know what "FFI" is, I would have to research that first to have any opinion. But the short term goal is to be able to easily share registered functions at least between script interpreter and plugins, because a plugin may implement any scripting language and use engine api to call the functions. Similar to how lua plugin was done in the past.
#3054
Please note: the Beta 3 has been reuploaded with a fix

The download links are all the same. I apologize for inconvenience.

Did this mostly because this was found within 24 hours; for any further problems i'd be making new releases as proper.
#3055
Engine Development / Re: Why is AGS slow?
Sat 16/04/2022 21:58:19
Quote from: eri0o on Sat 16/04/2022 21:13:00
About disconnecting the Script Runner, if it was less entrenched in the engine, this would make two things:


  • ease with improving it
  • reducing the barrier to connect other script runners (e.g.: Lua Jit)

As a note, this task will probably have to be completed in order to make engine not connected too hard to current interpreter:
https://github.com/adventuregamestudio/ags/issues/1223

as explained in the ticket itself, where it sais
QuoteThe way these "translator" functions are registered, and because they are using internal engine's types not meant for anything else, prevents from sharing same registration with other potential users.
#3056
We definitely need more testers. This mistake was made by a most recent change which I forgot to double check with all possible variants. Too bad that I dont have a good test game which would group similar functionality, like everything related to GUIs.
Or perhaps I should post temporary builds here to let someone try, instead of making a release?
#3057
@vga256, here's the engine with a fix, please tell if it works:
https://www.dropbox.com/s/0lnc6banecf0nti/acwin--3.6.0-beta3-guifix.zip?dl=0
#3058
This happens if the image has an alpha channel.
#3059
program pointer is +204 - this looks like a bug when processing room masks on load that was fixed some time ago, could you try updating to one the next beta versions?

E.g. this is Beta2: https://github.com/adventuregamestudio/ags/releases/download/v.3.6.0.22/AGS-3.6.0.22-Beta2.zip
Or most recent Beta3: https://github.com/adventuregamestudio/ags/releases/download/v.3.6.0.23/AGS-3.6.0.23-Beta3.zip

Quote from: tilapisha on Sat 16/04/2022 19:30:38all my GUI images are glitchy.

Could you be more specific please?

BTW, I think it's best to report these problems in the 3.6.0 Beta thread:
https://www.adventuregamestudio.co.uk/forums/index.php?topic=59842.0
#3060
Quote from: vga256 on Sat 16/04/2022 19:55:04
There appears to be a bug with b3, or a change in implementation that has rendered my BackgroundImages for GUIs to be completely transparent (or non-existent, not sure which). I can confirmed that all of my GUI windows have a proper BackgroundImage set. This was working fine with b2. Am I missing something obvious?

(FWIW - the Modem Dialer window uses a button with a background image as a background, not a GUI.BackgroundImage, which is why it appears correct)

Screenshot:

Please, can you give have some info about the game: color depth, which renderer do you run, and so on?

EDIT: actually yes, it does not work and displays a black rectangle instead of the image. This version is not working, I will have to fix and re-release.

EDIT2 it happens with some GUI but not the others, I am not exactly sure why yet.
SMF spam blocked by CleanTalk