Tyulis / 3DSkit

A multi-purpose and pluggable program to extract and repack files found in 3DS (and some other Nintendo consoles) games
GNU General Public License v3.0
68 stars 11 forks source link

UnsupportedDataFormatError: Unsupported texture format RGB565 (104) #25

Closed JokerDKha closed 3 years ago

JokerDKha commented 3 years ago

Help with Pokemon Ultra Sun And Moon bflim. image

Tyulis commented 3 years ago

That was a small error, it's fixed now. Thanks for you input !

JokerDKha commented 3 years ago

image Sorry for bothering you again, but how do I repack bflim to RGB565. I tried repack it many times but it shows RGBA8. The Hex file is here. Original File: image Pack File: image

Tyulis commented 3 years ago

Did you use the -O format=RGB565 command line option ? Even if the texture is not is the original format, usually it doesn’t cause any problem anyway.

IcySon55 commented 3 years ago

"Even if the texture is not is the original format, usually it doesn’t cause any problem anyway."

I would not recommend this. The game is using RGB565 for a reason, and that is VRAM. If you go around randomly increasing the size of textures and other images, you might crash the game if it runs out of memory. Then you'll be pulling your hair out trying to figure out what's going wrong!

JokerDKha commented 3 years ago

Did you use the -O format=RGB565 command line option ? Even if the texture is not is the original format, usually it doesn’t cause any problem anyway.

Now the pack is good but seem like is make picture error like this. Im used: 3dskit.py -pf BFLIM -O format=RGB565 image

JokerDKha commented 3 years ago

"Even if the texture is not is the original format, usually it doesn’t cause any problem anyway."

I would not recommend this. The game is using RGB565 for a reason, and that is VRAM. If you go around randomly increasing the size of textures and other images, you might crash the game if it runs out of memory. Then you'll be pulling your hair out trying to figure out what's going wrong!

Yeah the game is crash if using file not RGB565.

Tyulis commented 3 years ago

"Even if the texture is not is the original format, usually it doesn’t cause any problem anyway."

I would not recommend this. The game is using RGB565 for a reason, and that is VRAM. If you go around randomly increasing the size of textures and other images, you might crash the game if it runs out of memory. Then you'll be pulling your hair out trying to figure out what's going wrong!

You’re right, hence the "usually". I never got any problems with that, but this doesn’t mean it cannot happen. But it works with -O format=RGB565, I just got the time to double-check and resolved a small byte order problem by the way.

Now im the pack is good but seem like is make picture error like this.

If the latest commit doesn’t solve your problem, check that you use all the original options (-O format=<format> for the pixel format, -O swizzle=<texture swizzling option>), just as they are printed by the extraction command.

JokerDKha commented 3 years ago

It only pack single one output format like this. It cant pack 2 -o image

Tyulis commented 3 years ago

The packer-specific options are with an upper-case O In this case, 3DSkit.py -pf BFLIM -O swizzle=4 -O format=RGB565

JokerDKha commented 3 years ago

it still error like same way: image image

Tyulis commented 3 years ago

Oh, I see. I assume this file comes from a 3DS, so it must be little endian, but as BFLIM is originally a WiiU format, it is packed in big endian by default. You have to force little endian with the -l option

JokerDKha commented 3 years ago

still crashing a game and picture error image image

Tyulis commented 3 years ago

Ok, I double-checked everything, indeed it causes a game crash but I have no problem with the image whatsoever, so the problem might be elsewhere. I’m trying to investigate this.

Tyulis commented 3 years ago

I finally found several problems with subdirectories in the GARC and ALYT packers, especially on Windows. It’s now fixed, and it works image (Make sure you use version 6 when you repack your GARC with -O version=6)

JokerDKha commented 3 years ago

image Thank's for the support now anything working so fine <3

JokerDKha commented 3 years ago

Can you check about this file seem like it error. Im try repack this file and the game crash again. Location file: a1-2-5

image dec_2 5.zip

Tyulis commented 3 years ago

Well, it looks like it’s some sort of custom container that is incorrectly detected as a BFLIM by 3DSkit (hence the weird looping on the image). I think you’ll need to use an hex editor to extract the BFLIM part yourself (everything that is not highlighted here), convert the BFLIM with 3DSkit, edit it, convert it back to BFLIM, and put it back into the file. image As it is a custom format with no way to recognize it properly, there is not much I can do, sorry ^^

IcySon55 commented 3 years ago

That looks like a bad extraction, as if the archive tool has the offsets wrong. :thinking:

Looks more like it should start at SARC which is a known archive format.

JokerDKha commented 3 years ago

That looks like a bad extraction, as if the archive tool has the offsets wrong. 🤔

Looks more like it should start at SARC which is a known archive format.

Im try delete First Hex File and extract the SARC. image The file now can extract Common_Grpfont_Icon But now i dont even know how to put it back :(

IcySon55 commented 3 years ago

Hmm, I know our tools support SARC. Have you heard of Kuriimu? Or perhaps you're asking about how to put it all back in the end, like restoring the stripped bytes before SARC. I haven't looked into these files that deeply so I'm short on details.

How many layers of extraction are we at before getting to the BFLIM? Like how many archives deep are we and what are the filenames and types?

JokerDKha commented 3 years ago

Hmm, I know our tools support SARC. Have you heard of Kuriimu? Or perhaps you're asking about how to put it all back in the end, like restoring the stripped bytes before SARC. I haven't looked into these files that deeply so I'm short on details.

How many layers of extraction are we at before getting to the BFLIM? Like how many archives deep are we and what are the filenames and types?

Im trying used Kuriimu too but it still error. Can you check help me check out this file? Here is the file: dec_2.zip

Tyulis commented 3 years ago

Hmm, I know our tools support SARC. Have you heard of Kuriimu? Or perhaps you're asking about how to put it all back in the end, like restoring the stripped bytes before SARC. I haven't looked into these files that deeply so I'm short on details. How many layers of extraction are we at before getting to the BFLIM? Like how many archives deep are we and what are the filenames and types?

3DSkit supports SARC as well, but there’s a custom header with no way to recognize it properly, and it is probably only used here.

Tyulis commented 3 years ago

But now i dont even know how to put it back :(

You can directly copy the reconverted file’s content in place of the old one with an hex editor

Tyulis commented 3 years ago

That looks like a bad extraction, as if the archive tool has the offsets wrong. 🤔

It’s not, I double-checked the GARC content and the files are extracted properly

JokerDKha commented 3 years ago

But now i dont even know how to put it back :(

You can directly copy the reconverted file’s content in place of the old one with an hex editor

Im use HxD but dont know how to import or replace the file.

Tyulis commented 3 years ago

Just replace the original content at the original position by the new one by copy-pasting

JokerDKha commented 3 years ago

Copy like that make a files error. Im use File edit sarc and i copy original content form old file to new file like this. image

Tyulis commented 3 years ago

Are you sure you pasted it at the original position, and that you replaced the original content (by selecting it before pasting such that it is overwritten) ? It should not give you any "file size changed" warning

JokerDKha commented 3 years ago

Original File: image Edited File: image

Tyulis commented 3 years ago

Ok, so if you’re sure you put the data correctly, what kind of error do you get ?

JokerDKha commented 3 years ago

Ok, so if you’re sure you put the data correctly, what kind of error do you get ?

Im try repack a game with edited file, and the game crash. The file edited cant extract(3dskit) or view(Kuriimu,SwitchTool) again.

Tyulis commented 3 years ago

What’s weird is that I have no problem whatsoever image

Tyulis commented 3 years ago

Oh, I found your problem. I’m trying to fix it, it’s in the pure-python compression part

Tyulis commented 3 years ago

It should be fixed by the latest commit

JokerDKha commented 3 years ago

Working 100000% Thank's you <3 image

JokerDKha commented 3 years ago

Sorry for bothering you again but im need help for extract Z-move sprits but i dont know how to open this file and extract it. Im using 3DSkit and it print like below: No compression UnrecognizedFormatError: Unrecognized format (102) dec_2.zip

Tyulis commented 3 years ago

It seems like a custom texture format, so it’s not supported by 3DSkit The header mentions a TGA file, but it doesn’t look like one.

JokerDKha commented 3 years ago

im find out we can Export with this: https://gbatemp.net/threads/wip-ultra-sun-and-ultra-moon-pokemon-models-textures-and-animations.490365/ But now i dont think this tool will let saving again after editing a picture :( image EDIT: I find out the way to replace the tex. Tks and sorry bothering you <3

IcySon55 commented 3 years ago

Hey there guys. Just figured I could chip in here specifically on dec_2.bin.

The image is 3DS Z-Order ETC1A4 encoded, 512 x 256: image

And here's the image saved to PNG: dec_2 bin

The file header leaves much to be desired but an image plugin for this is certainly doable. :)

JokerDKha commented 3 years ago

Nice is so good to hear that, if kuriimu have image plugin for this tex. It so easy for edit picture in game. There is so much file in this game using image is 3DS Z-Order ETC1A4 encoded in game.

IcySon55 commented 3 years ago

A plugin would need to be created of course, but that shouldn't be that difficult if somebody wants to give it a go. I don't have that much time on my hands these days. ;_;

JokerDKha commented 3 years ago

After Edited file with Ohana3DS sun-moon, the file will not working after repack. Header like below: Edited: 1 Original: 2

Tyulis commented 3 years ago

Making a 3DSkit module is certainly possible, but this require some investigation on the format first, I’ll try to give it a go today

Tyulis commented 3 years ago

The format seems fairly simple, I hacked something together that seems to work. ETC1 and ETC1A4 compression is not supported yet, but it might work with more standard formats like RGBA4 or RGB5551, could you please check ?

Conversion to PNG is as usual, to convert it back it’s with the PkmSMTexture format : 3DSkit.py -pf PkmSMTexture -o <output file> -Oformat=<texture format> image.png

The image file name is important as it is stored inside the file and presumably used to identify it in other models and scenes, so keep the filename given when 3DSkit extracts the file.

JokerDKha commented 3 years ago

Report more error big file GARC cant repack RGB5551 is not support and RGBA4 is not working. Im try repack with pk3DS Sample: https://drive.google.com/file/d/1rC3KI-TYiVoJdPa9d1X1_0uK6bMEIUFP/view?usp=sharing error packed

Tyulis commented 3 years ago

It’s RGBA5551, not RGB, sorry for the typo I just fixed some regressions in the last updates, ensure you use the latest commit. Don’t forget the -d option when packing an archive, otherwise it won’t pack it properly, your error might be because of this.

If repacking in another texture format does not work I’m afraid I won’t have time to implement it any time soon, ETC1 compression is currently not supported and would be much more complicated to implement, and I don’t have free time for that at the moment.

JokerDKha commented 3 years ago

RGBA5551 still not working too Sample file ez_cmn_name_02_usa.zip .

Tyulis commented 3 years ago

I could successfully replace one of those ETC1A4 texture in RGBA4 format, so check that you used the right options, did not forget to remove your working files from the GARC directory before packing, did not inadvertantly renamed a file, … image

For reference, the command to convert the texture back : 3DSkit.py -pf PkmSMTexture -o whatever\dec_3.bin -Oformat=RGBA4 whatever\ez_cmn_name_03_fra.png And to repack the GARC : 3DSkit.py -pdf GARC -o 7 -Oversion=6 whatever\7_

IcySon55 commented 3 years ago

@Tyulis Regarding replacing textures with other pixel formats. I imagine that your script updated the format identifier in the header accordingly. However, RGBA4 likely produces a larger file and thus eats more VRAM while in-game. I've often seen this cause games to crash because their ram allowance is usually well used by the devs.

In short, I do not recommend changing the pixel format when modifying game graphics. Especially on low-spec hardware like most handhelds.

JokerDKha commented 3 years ago

@Tyulis it working so Fine now, but repack GARC is take so long maybe 30-45min. But thank's for your help, im will update soon if any error show in testing game.