Room masks import is not usable

Started by Crimson Wizard, Wed 28/02/2024 17:32:27

Previous topic - Next topic

Crimson Wizard

A recent conversation on Discord have reminded that importing masks into AGS (for walkable areas, hotspots, etc) is simply not usable.

Not every graphic software can export into 8-bit bitmap format, and those which can, they not necessarily allow to configure the palette. This means that the image will have colors randomly given palette indexes, making it impossible to predict area numbers. In the best case software will assign indexes starting from 0 and up, but others might choose arbitrary indexes in the full range (0-255), while editor cannot use those above "max area number" limit (16 for walkable areas, for example).

Even if image is "successfully" imported, this means the trouble is only postponed, because any change to the existing image may shuffle these indexes again, in which case reimport will break area indexes, forcing user to reapply all properties and events.

This is a critical problem, in my opinion, and this makes me very confused about how people work with the room masks at all, all these years; and why this problem is not set among the topmost priorities, and not discussed on forums. Because this is a fundamental functionality required to make rooms, and it is not reliable if at all usable.

Snarky

#1
I think you're somewhat overstating how much of a problem this is. Maybe not all graphic software can export to 8-bit, but most can (including Photoshop), and in my experience you can get them to assign to the first 16 (or however many) palette slots fairly easily.

If another export shuffles the palette order, there are two workarounds: you edit the file before you import it into AGS, or you switch the regions around in AGS (using the paint bucket to fill each region with the right number). It's a little bit of a hassle, but not a catastrophe. And it's really a problem with the graphic software, not AGS.

I believe most people who use this workflow figure out how to make it work reliably and efficiently.

That's not to say that it wouldn't be helpful to have a dialog to e.g. map palette indices to region numbers, since that could simplify the workflow a little, especially for newbies.

Alan v.Drake

I use paintshop pro and never had a problem just saving an indexed image. Photoshop works fine too (it has indexed mode and a color table palette where you can save/load colors).
Gimp should be able too, if you remove checkbox from unsafe options that remove unused colors, but I never used Gimp.

Maybe we can go forth with the idea of deciding an universal mask palette, and let AGS match those exact colors when importing a non-indexed mask image.

To note, if someone makes an optimized export in their program of choice, colors might still end up messed up. "Export for web" and other similar features are never really safe for accuracy. Never use "export" options, when color is crucial.

- Alan

eri0o

I use my masks through Aseprite and never had a problem moving palette indexes there. Most of the issues in importing for me were that AGS demands exact 256 colors in the index, but I just created my palette for this and resorted to using that and it works.

I think it would be better to make the controls in the editor more useable, either with adding undo (and redo), brushes of different sizes and things like that or adding the polygons there too.

Crimson Wizard

#4
Well you say it's not a problem, yet there is a person on Discord right now who spent 2 days trying and failing. In my eyes this is a horrendous result for this most basic feature.

If the AGS functionality requires using very particular graphic program which supports very particular export methods, and then still keep using workarounds, then that IS a problem with AGS. This means that AGS does not provide a easy solution.

And since I'm at that, I might say that this habit of brushing AGS problems off, preferring to keep the "workarounds" tactic, is probably the reason why there are so many issues in its core functionality still after many years. People just get used to "workarounds" and don't bring problems up. Then every newcomer gets into a trouble.

And of course these nuances are never documented, so I cannot even find a reference when someone asks about a problem.

Quote from: Alan v.Drake on Wed 28/02/2024 19:03:06Maybe we can go forth with the idea of deciding an universal mask palette, and let AGS match those exact colors when importing a non-indexed mask image.

I've been thinking about similar thing, have a "import mask" palette, optionally enabled, which has default color setup for masks. I don't think the regular game palette may be used for this, because it is divided between "game" and "room" colors, which may make using it for masks palette inconvenient.

Quote from: eri0o on Wed 28/02/2024 20:21:01I think it would be better to make the controls in the editor more useable, either with adding undo (and redo), brushes of different sizes and things like that or adding the polygons there too.

I don't know how useful having a mask drawing tools inside editor would be, besides being able to quickly setup a scene draft. I know that at least a portion of users prefer to be drawing masks over their room backgrounds as layers, because that lets them keep things in sync whenever background changes, and keep everything in a single image document. In the past some people even complained that they cannot update their rooms without launching the editor, wished there was a command-line tool that would do this for them. Such approach may become even more suitable in AGS 4 where room masks and backgrounds are standalone files in game folder, so one may export over them without opening an editor.

In  any case, having one method does not prevent having another.

But fixing the mask import now seems like a higher priority to make things smoother for newcomers, and possibly much easier to implement.

Snarky

#5
Quote from: Crimson Wizard on Thu 29/02/2024 03:01:33And since I'm at that, I might say that this habit of brushing AGS problems off, preferring to keep the "workarounds" tactic, is probably the reason why there are so many issues in its core functionality still after many years. People just get used to "workarounds" and don't bring problems up. Then every newcomer gets into a trouble.

The point I was making is that I don't think most users experience this as a serious problem.

I'm not sure whether the user on Discord was unlucky in what graphic software they tried to use, or just couldn't figure it out, but if this was really a problem "every newcomer" struggles with, we would hear about it way more often. (Compare all the questions about linking events and event handlers.)

Quote from: Crimson Wizard on Thu 29/02/2024 03:01:33And of course these nuances are never documented, so I cannot even find a reference when someone asks about a problem.

Isn't it all documented here? It doesn't explain how to actually create files in the required format, but since that will vary from image editor to image editor, that wouldn't be possible to document in general.

Quote from: Crimson Wizard on Thu 29/02/2024 03:01:33I don't know how useful having a mask drawing tools inside editor would be, besides being able to quickly setup a scene draft.

I would expect most people do use the AGS mask editor (supporting that as a higher priority), and that the mask import feature is more of an "advanced option."

BTW: It's been a while since I used it, but my recollection is that AGS doesn't export masks in the same format it requires them to be when imported. (You can only export one mask at a time or something?) If that's so, it should be an easy fix that could also help with creating files in importable states (you could just export the masks to a file, paste the drawing you've made into it, and resave).

Quote from: Crimson Wizard on Thu 29/02/2024 03:01:33I've been thinking about similar thing, have a "import mask" palette, optionally enabled, which has default color setup for masks. I don't think the regular game palette may be used for this, because it is divided between "game" and "room" colors, which may make using it for masks palette inconvenient.

If you're absolutely convinced this is a high priority, I would suggest an import screen where you could see the mask image and a list of the mask channels. Then with an eye-dropper tool you could assign each color to a channel. A default mapping of colors to channels (if they match) would then be a nice-to-have accelerator feature.

But realize that as soon as you move away from requiring palette-indexed images, you're going to have users who try to use anti-aliased, compressed or otherwise not 100% RGB-accurate masks.

Crimson Wizard

#6
Quote from: Snarky on Thu 29/02/2024 07:09:31I would expect most people do use the AGS mask editor (supporting that as a higher priority), and that the mask import feature is more of an "advanced option."
<...>
I would suggest an import screen where you could see the mask image and a list of the mask channels. Then with an eye-dropper tool you could assign each color to a channel. A default mapping of colors to channels (if they match) would then be a nice-to-have accelerator feature.

I see that our views on this are complete opposite.

IMO it is a norm in software that data comes first and GUI second. The GUI is another way to edit the data. This approach helps to keep things organized and consistent. GUI also stands in a way of automation. A process cannot be automated (e.g. to run full game compilation from the source assets) if there are steps which may only be accomplished with GUI.

If you look into AGS 4, where rooms are stored in an "open format", you would see that masks are just plain files, and it's only a matter of whether they are edited in a graphic software or within AGS Editor. This means that the "mask import" is no longer a "side feature", but a process that is run always when preparing a room data regardless of how it was created.

For these reasons, I believe that having a mask prepared as an asset for the game compilation, and strict rules of converting this asset to in-game object - are a priority, while any GUI tools to change that mask within the editor come after that.

For the same reasons, having any interactive screen that lets map image colors to areas has to be considered an optional step, and priority is to have this mapping organized in data first, with default settings.


Quote from: Snarky on Thu 29/02/2024 07:09:31But realize that as soon as you move away from requiring palette-indexed images, you're going to have users who try to use anti-aliased, compressed or otherwise not 100% RGB-accurate masks.

I am not certain about non-indexed images, I'd start with making sure that indexed images work.

Quote from: Snarky on Thu 29/02/2024 07:09:31Isn't it all documented here? It doesn't explain how to actually create files in the required format, but since that will vary from image editor to image editor, that wouldn't be possible to document in general.

This documents the basic idea, but it does not explain the potential issues. I think it should mention which export settings to use in the contemporary graphic editors, and that some editors may cause area indexes to swap when adding more areas.

eri0o

If you export a mask, open it in an image editor, save without changing the format and import back it should work, no?

Also when I mentioned the Room Editor is because the idea of AGS is you can do everything in the software itself and the most people I observed their workflows do actually use the room Editor despite it's limitations.

The issue the person may have is their software saves palette with alpha and palette with alpha is only fixed in AGS4 I think.

Crimson Wizard

#8
Quote from: eri0o on Thu 29/02/2024 10:13:46If you export a mask, open it in an image editor, save without changing the format and import back it should work, no?

Besides format, another problem is shuffling of the color indexes. Not all graphic software seem to keep these, some seem to rebuild palette on each save, and some of those seem to be using absolutely arbitrary numbers instead of starting from zero and going up.

A person whom I mentioned above ended up with painting a bit of each single area color on a mask, and exported it with intent to use it further. This supposedly keeps used indexes locked in his graphic software.

But that's a workaround, and I want there to be a clear solution that just works without strange actions. A person should be able to draw and save an indexed bitmap, and pass it to AGS, knowing that it will be accepted and lead to expected results.

eri0o

Besides all of that, if you tell me the graphics software I will open a bug in their bug tracker wherever it is telling to not shuffle colors because I haven't seen this behavior in Aseprite, Gimp, Graphics Gale, Krita or Photoshop. Seriously, can't think a graphic Editor that does this.  :-\

Snarky

Quote from: Crimson Wizard on Thu 29/02/2024 10:22:51Besides format, another problem is shuffling of the color indexes. Not all graphic software seem to keep these, some seem to rebuild palette on each save, and some of those seem to be using absolutely arbitrary numbers instead of starting from zero and going up.

A person whom I mentioned above ended up with painting a bit of each single area color on a mask, and exported it with intent to use it further. This supposedly keeps used indexes locked in his graphic software.

But that's a workaround, and I want there to be a clear solution that just works without strange actions. A person should be able to draw and save an indexed bitmap, and pass it to AGS, knowing that it will be accepted and lead to expected results.

If the problem is that external software behaves in inconsistent ways, there's no way to avoid the need for a "workaround" to make it work with AGS. You can adapt the way AGS works to this other behavior (for example map the channels based on color value instead of palette index), but that will break existing workflows.

Crimson Wizard

#11
Quote from: eri0o on Thu 29/02/2024 11:31:19Besides all of that, if you tell me the graphics software I will open a bug in their bug tracker wherever it is telling to not shuffle colors because I haven't seen this behavior in Aseprite, Gimp, Graphics Gale, Krita or Photoshop. Seriously, can't think a graphic Editor that does this.  :-\

I tried MS Paint and Paint.NET.

The new MS Paint is a weird program (it became really strange since Vista or Win7, the original one was at least suitable for pixel art), and when saving 8-bit BMPs it assigns indexes using an unknown rule. E.g. I had 3 colors on bitmap and it assigned indexes like ~150 and ~220.

Paint.NET seems to number colors from 0 up in a sequence, but it looks like remapping colors each time you open, edit and save an image. (It's quite possible that it looses the original palette info upon loading image up.) Indexes are applied to colors met if going from top-left to bottom-right, so if you first draw an area at the bottom, then later another one at the top, then the indexes will swap.

The person on Discord has been using Gimp, and according to him Gimp had similar problem to MS Paint where it would assign way too high color indexes, making bitmap unusable for AGS mask. At least it seemed to keep existing indexes after exporting a mask from AGS.


Quote from: Snarky on Thu 29/02/2024 11:39:38If the problem is that external software behaves in inconsistent ways, there's no way to avoid the need for a "workaround" to make it work with AGS. You can adapt the way AGS works to this other behavior (for example map the channels based on color value instead of palette index), but that will break existing workflows.

I've been considering the color mapping as an option, which user could enable for their project if they prefer, to match their software (or rather assets).

RootBound

I'm going to look like a complete newbie here, and maybe that's still what I am after using AGS for only 1 year, but I have never been able to figure out how to make importing room masks work, and have resorted to using the editor tools even when this is a pain.

I'm also someone whose computers growing up skipped over 8-bit. My family was working class and held onto our old EGA computer for so long we jumped up to 16-bit when we replaced it.

I have, even now, no idea how to create the particular 16 colors that AGS wants, in any graphics program (I use GIMP, MSPaint, and LibreSprite (an Aseprite branch)).

Creating images that are limited to 16 or 256 colors is easy. Creating indexed images like .png is easy, and they can at least be converted to the .bmp format that AGS needs.

But finding the exact colors and order that AGS wants is not easy. I still have no clue how to do it.

I can download an 8-bit palette no problem, but AGS seems to have a particular order in mind for the 8-bit palette and I can find no way to figure out what that order is and therefore what the "first" 16 colors of it should be.

I can google 8-bit palettes all day, but that's no help in telling me which particular 16 colors AGS wants. I've had some colors show up and others not be imported because they aren't the right index.

Hence the giving up and using editor tools. I have never complained about it or asked about it in the forums because even after reading the documentation, I could tell that figuring out how to use any of my preferred graphics programs to do this was going to be another complicated step.

8-bit tools and palettes are so outmoded at this point that most graphics programs, in my opinion, require expert knowledge in order to somehow locate the 16 colors AGS wants.

Maybe this post makes me look young and silly and very, very unintelligent. So be it. But I have been using computers and graphics programs my whole life, and in this particular case, I still don't know how to give AGS what it's looking for.
They/them. Here are some of my games:

Babar

For reference, I'm the user on discord who was having problems. As mentioned, I was using GIMP, but also tried Windows Paint program.

As CrimsonWizard mentioned, I ended up creating a mask in AGS by just randomly placing 15 squares of different colours, exporting that mask, and now I'm pasting my new masks onto that image whenever I need.

Also for reference, the link Snarky shared is either not valid, or contradicts AGS's own error message, which told me that only 256 colour BMPs are permitted. Also, AGS now allows more than 15 hotspots, but the method mentioned in the link would only allow for 15.
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

eri0o

#14
Here's GIMP how it works
Spoiler


In the left, in the tools, you have to use the maximum hardness and you have to use pencil. In the right, you can either select any palette that has 256 colors exactly or create your own.

Then in the palette, the colors are in sequence, so the first is eraser, the second is the first mask and so on.



Then you export a bmp and then you import in ags

[close]

I really think it should be possible to import png files, but I think this was already adjusted in ags4.

Crimson Wizard

#15
I found how to make a indexed image in GIMP, I found the palette, but I could not make it export as a 8-bit BMP. It always exports as 4-bit BMP for some reason, which AGS does not accept. When I try export as PNG, it exported a 2-bit PNG...

How do I tell GIMP to export 8-bit BMP, or 8-bit PNG exactly?
(I downloaded GIMP 2.10.36)

I suppose AGS could just support any format starting with 8-bit and lower, BMP and PNG, because all of those are indexed formats, so it should not really matter?
EDIT: I did a quick test, and for some reason .NET cannot convert between 4-bit and 8-bit image properly on its own (using Bitmap.Clone to copy image with a different PixelFormat), as it shuffles palette for some reason. Maybe I missed some option, idk. I was able to get a better result by manually copying pixels in the native code.


I think what we need is a "Knowledge base", with explanation for each popular graphic software. How to create a indexed image, how to work with palette, how to save/export for AGS. Then this "knowledge base" could be refered to whenever user is in trouble.

Because I know almost nothing about graphic softwares, and I cannot explain anything to people when they post in tech support channel!

Crimson Wizard

#16
I was able to force GIMP to save a 8-bit BMP by adding enough colors to palette. I think you need at least 17 colors to be in the color map for this (because 4-bit index may have values 0-15).
This BMP can be imported by AGS, and assigns correct areas. So I confirm that this method works, except there are couple of annoying nuances. But I never used GIMP in indexed mode, so maybe I am missing easier ways to do what I want.

Snarky

Quote from: RootBound on Thu 29/02/2024 13:11:25I can download an 8-bit palette no problem, but AGS seems to have a particular order in mind for the 8-bit palette and I can find no way to figure out what that order is and therefore what the "first" 16 colors of it should be.

I can google 8-bit palettes all day, but that's no help in telling me which particular 16 colors AGS wants. I've had some colors show up and others not be imported because they aren't the right index.

It doesn't matter what the first 16 colors are. In principle they can all be the same color, for example black (though that would of course make it very difficult to edit the image).

I suspect that you don't fully understand how a palette-indexed image format works. It's not just any image with a limited number of colors, but a particular way of representing an image. It means that for each pixel in the image, you don't store the color directly, but just an index to look up the color in a table (the palette). This allows you to draw an image without committing to a particular color scheme: that car might be red or green or blue, just by switching out the palette. Or you can do an effect like hidden writing, where you have two different index values that both map to "white" initially, but by changing the palette, one of them turns dark so the text appears. And lots of other things.

The point is that the palette, the mapping from index value to color, is separate from the image data itself. In some cases, the palette is even omitted entirely (for example because it follows some implicit default, or is stored in a separate file)—though not in the file formats AGS supports.

The color a particular index is mapped to (defined in the palette) doesn't matter to AGS because AGS is merely using the image to assign masks straightforwardly: pixels with index 0 are assigned to mask 0, 1 to 1, etc.

AGS only supports 8-bit palette-indexed images for importing masks (which gives an index range from 0 to 255). And since AGS only has a limited number of mask channels, the pixels in the image need to be using the lower part of the range of palette indices.

The problem is that since most people aren't creating their backgrounds in a palette-indexed format in the first place (and most modern image editing software has limited/unintuitive support for palette editing), they're usually converting the mask image from another format, which means that the palette index selected for each color ends up being "random." This is what's causing most of the difficulties.

RootBound

@eri0o @Crimson Wizard @Snarky Thank you for your responses. Sorry if my tone in my previous post was a bit harsh. This is something I've had a hard time with for a while, and it always seemed like the manual ought to be enough for me to understand it, when ultimately I think there needs to be more detailed clarification there (see below for suggestions).

But I think I finally get how this works, and how indexed images work. I was able to use LibreSprite (which like aseprite makes it very easy to edit palettes) to create an indexed .bmp with at least 17 index slots used (0-16), and was able to import it into AGS as a walkable area mask, with all the areas preserved and index 0 as no area. So, success.

Something that could be useful, perhaps, is to add some of the following clarifying instructions to the manual page:

-Make sure the image is the same resolution as the room you're importing it into.
-Make sure you save the image in indexed color mode. (It seems to me that it's possible to save an image to 8-bit without it being indexed - I think this was what confused me before).
-Use a graphics program which allows you to see which colors are indexed as #0-15, and use only those colors. (This may be partly stated already, but clarifying it would have helped me understand it better).
-Make sure the image saves specifically as 256 colors, and that the colors you have used are not shuffled out of slots 0-15.
-If any of these conditions is not met, the mask will not import properly.

Hopefully, this would help users like me to understand and navigate better what AGS needs for its masks.

If it's helpful, here's the image I was able to use, an indexed 8-bit .bmp with only slots 0-15 using bright colors and index 16 filled with an off-black just to bump it up to 8-bit.

They/them. Here are some of my games:

Khris

I'm still using Paint Shop Pro 7.

All I do is draw a bunch of areas in arbitrary colors, then select "Reduce colors -> 256 colors" from the menu. I confirm the algorithm prompt and end up with the used colors in the first slots of the new 256 color palette, with the background color ending up in slot 0.

Next I save this file as png and can now import it into AGS, which works flawlessly. I don't even have to recolor anything (unless I want the main area to be in slot 1 or something).

SMF spam blocked by CleanTalk