grunt-lucas / porytiles

Overworld tileset compiler for Pokémon Generation 3 decompilation projects
MIT License
35 stars 3 forks source link

Fatal error: palette assignment parameter search matrix failed to find any suitable parameters #2

Closed purrfectdoodle closed 9 months ago

purrfectdoodle commented 9 months ago

Me again lol, I'm trying to generate a tileset using compile-primary and I have the following error:

warning: ./my-tileset/assign.cfg: cached compilation settings not found [-Wmissing-assign-config]
note: running full parameter search matrix, this may take awhile...

fatal error: palette assignment parameter search matrix failed to find any suitable parameters
note: please see the following wiki page for help with working through this error:
      https://wiki-page-link-goes-here.com
terminating compilation of ./my-tileset/

This might be relevant: I was having the "running full parameter search matrix, this may take awhile..." message for a long while, and I accidentally closed the terminal. When I ran the command again, I got this error.

[EDITED] I'd like to avoid losing all the maps I've made using the previous iteration of this tileset; is there a way to rollback what Porytiles has done without losing everything?

Just for context, these are my three .PNG images: bottom middle top

grunt-lucas commented 9 months ago

Unfortunately this isn't really a bug with Porytiles. Rather, it's the message you get when the palette assignment algorithm is unable to find an allocation that covers all of your tiles. Palette assignment is a variant of the bin-packing problem, which doesn't have a known polynomial time solution. Porytiles has to do a lot of clever tricks to find a solution in most cases. Over time, I will continue improving these tricks so that this error message is less frequent, but as it stands it's not a bug.

So how to solve this error message? Typically, you either need to reduce the number of unique colors, or better layerize tiles with conflicting color families. For example, you have a lot of tiles in your Pokécenter that mix reds with greys and blues. If you separated that out better (for e.g. by putting the entire red roof on its own layer, putting the red P.C. and Pokéball symbol on their own layer, etc) you might get better results. If you're in the RHH discord server, go ahead and ping a user named voluptua. He had this problem and I helped him fix it -- he can probably show you an example of how he layerized his Pokécenter.

Hope that helps.

Edit: If I get some time I will download your three layer PNGs and see if I can modify them a bit so they will compile.

I'd like to avoid losing all the maps I've made using the previous iteration of this tileset; is there a way to rollback what Porytiles has done without losing everything?

Also, if you are not using Git to track your project changes I highly suggest you drop everything and learn the basics now. It will save you so, so many headaches in future :)

purrfectdoodle commented 9 months ago

Sorry about the bug label, I don't know how it got there. I wasn't trying to report an actual bug, but I opened this issue because the error message was (to me) unclear and I thought it wasn't an error message that the end user was supposed to see (I thought Porytiles had been cut off while editing the project files in pokeemerald and had basically corrupted the tileset portion of it). My bad. Maybe a FAQ or error-related section in the wiki with the main error messages and their explanations could help other people with similar issues?

If you're telling me that it's just the .PNGs themselves that are the issues, that's pretty reassuring, I'll just keep tinkering with them (and maybe ask voluptua on Discord if I get really desperate lol) and eventually it'll work :)

I absolutely do use Git and love it :) I just hadn't committed yesterday's changes (bad, I know) and was afraid of losing them.

Thanks again for the help and kindness and for porytiles!

purrfectdoodle commented 9 months ago

Maybe a FAQ or error-related section in the wiki with the main error messages and their explanations could help other people with similar issues?

I know you're doing unpaid work and probably busy with more important stuff, so if you want I can start by creating that page myself and put in this error and quoting your explanation (not entirely sure if I can open a PR for the wiki itself, but if this is something I can do I'm all for it)

grunt-lucas commented 9 months ago

Sorry about the bug label, I don't know how it got there.

Oh don't worry about it. I realize that error message definitely makes it sound like something buggy is happening. As you can see in the error message, there's a placeholder wiki link there (since I haven't gotten around to writing an explanation wiki page yet). My eventual aim is to have a video tutorial series as well, but you know how it goes, only so many hours in a day.

I thought Porytiles had been cut off while editing the project files in pokeemerald and had basically corrupted the tileset portion of it

Ahhh ok I see your concern. Nah you are good. Porytiles doesn't write any files until the very end. So if you cancel it partway thru the assignment search, it will just exit.

If you're telling me that it's just the .PNGs themselves that are the issues, that's pretty reassuring, I'll just keep tinkering with them (and maybe ask voluptua on Discord if I get really desperate lol) and eventually it'll work :)

Yeah just keep tinkering with it and eventually you should find something that compiles. I'll try tinkering at some point too. I like to tinker with user images when they hit this case, because it gives me insight into how I can improve the bin-packing heuristics, or tweak the algorithm in general.

not entirely sure if I can open a PR for the wiki itself, but if this is something I can do I'm all for it

Yeah I am also not sure how to (or if you can) do that on GitHub. But don't worry about it! I'm just happy users are filing issues, because it means somebody is actually using it :)

lsfgrd commented 3 months ago

Hi @grunt-lucas! I know this is a closed issue, but I stumbled on the same problem and this thread actually gave me a lot of insights, so thanks for explaining!

Now I was wondering if this is something porytiles can give more information to the user, so they can go and fix that themselves. Thinking that it would be useful if it could output what colors could be removed from the pallete so it helps the algorithm. Altough I believe this gets obvious if you look at your tileset colors in an interface like the one from Aseprite:

image

In my case the CP colors also were the problem. It definitely would be helpful if porytiles could tell that to me somehow.

I'm fairly new to the GBA world so sorry if what I'm saying doesn't really make sense. I admit I also didn't look in depth on how the program works, but I'd love to help with that if it is something feasible and desirable. I'll try to test some changes in the code myself but I'm not used to cpp programming so it will take a while!

grunt-lucas commented 3 months ago

@lsfgrd that's a great suggestion. I recall someone made a similar suggestion to me in a Discord chat somewhere. An idea would be for Porytiles to try automatically removing colors that are similar, recompiling, and seeing if that works. If so, it could report that to the user.

I need to think about this a bit more. Because sometimes, it's not color count that's an issue. Sometimes the user can simply layerize tiles better and it will compile with the same color count. So I wouldn't want the feature to mislead users into thinking they need to settle for a sub-par color distribution. Ideally I want people to understand how pokeemerald tilesets work so they can think it through themselves. Ideally, Porytiles should be a tool that helps you speed up a process you already understand, not a tool that does "black magic" to make your tile PNGs work in-game.