Is it Possible to Import Textures into .bch Files Without Significant Quality Loss? (FE: Fates)

Discussion in '3DS - ROM Hacking, Translations and Utilities' started by UnassumingVenusaur, Mar 28, 2016.

  1. UnassumingVenusaur
    OP

    UnassumingVenusaur In All Her Gay Glory

    Member
    456
    232
    Nov 20, 2015
    United States
    So, I've been attempting to insert custom sprites into Fire Emblem Fates as of late. The character sprites are saved as textures (.png's, it seems?) in .bch files. I've been using Ohana 3DS to do this. However, I've recently learned (and seen in-game) that when the texture is imported into Ohana, it becomes compressed in ways that corrupt the quality of the sprite. For example, I tried to import a custom short-haired sprite for Lucina. It loaded up in-game, but the reduced quality and discoloration from the compression was obvious-- even more so in-game than in these screenshots.

    top_0017.png top_0001.png
    Original

    top_0000.png top_0001.png
    Custom
    Apparently, Ohana 3DS Rebirth doesn't compress the textures, but it saves .bch files at a rather large size that makes it unusable in-game. The people I've talked to and asked don't know of a program besides Ohana for this sort of editing, but I really don't want to settle for these lower quality sprites, so I thought I'd at least ask here to see if on some off chance someone knows a solution. Is there any other program that I could use to replace the textures in a .bch file that would circumvent this corruption of the sprite, but also save properly? Really, is there any way at all? I'm willing to try anything, honestly. Even if there were some way via hex editing.
     
  2. Thelostrune

    Thelostrune GBAtemp Advanced Fan

    Member
    546
    128
    Aug 13, 2015
    Norway
    How so exactly? Does it refuse to build?
     
  3. UnassumingVenusaur
    OP

    UnassumingVenusaur In All Her Gay Glory

    Member
    456
    232
    Nov 20, 2015
    United States
    To be fair, for some reason when I tried to use Ohana 3DS Rebirth I couldn't even get it to open the .bch file, but I think I was just doing something wrong there. The info about how it saves I was told by another person who *has* tried it. They told me:

    "Rebirth forgoes [Ohana's] compression bc it was causing the photos to lose quality (the problem the old ohana has). So basically rebirth will save the bch files at a much larger size than the original files bc they're not etc1/etc2 compressed, and they won't work in game."

    They were even trying it with Fire Emblem Fates sprites as well, so I'm taking their word for it that it won't be a solution for me.
     
  4. Thelostrune

    Thelostrune GBAtemp Advanced Fan

    Member
    546
    128
    Aug 13, 2015
    Norway
    No shame in trying that anyway. If there's a post that they made somewhere, I would like to see the context for everything here. I don't know the specifics for the FE:Fates fs or the files.
    I could look at the bch, though. It's been a month since Rebirth had any changes and still just support for .bch files, which is kinda shit.

    Please do give out any information on this, as I am struggling with the same issue as well.
     
    Last edited by Thelostrune, Mar 28, 2016
  5. UnassumingVenusaur
    OP

    UnassumingVenusaur In All Her Gay Glory

    Member
    456
    232
    Nov 20, 2015
    United States
    Ha! I tried to use Rebirth and this is what I got:

    top_0000.png
    Also, that quote was actually part of a message sent to me on another site.
     
  6. Thelostrune

    Thelostrune GBAtemp Advanced Fan

    Member
    546
    128
    Aug 13, 2015
    Norway
    oh god
    Could you upload the original file of which you are modifying? I could take a look at it.
     
  7. UnassumingVenusaur
    OP

    UnassumingVenusaur In All Her Gay Glory

    Member
    456
    232
    Nov 20, 2015
    United States
    Here ya go! This .zip contains the .arc file the .bch was originally a part of, the .bch.lz it was originally compressed as within that file, the decompressed .bch, and the texture I was trying to import into the file.
     
  8. Thelostrune

    Thelostrune GBAtemp Advanced Fan

    Member
    546
    128
    Aug 13, 2015
    Norway
    What exactly is the arc file for and what does it contain? It has a weird header, but says BCH.
     
  9. UnassumingVenusaur
    OP

    UnassumingVenusaur In All Her Gay Glory

    Member
    456
    232
    Nov 20, 2015
    United States
    The .arc file contains quite a few sprites bunched up into one file, including the sprite i'm trying to edit. I decompressed it simply by dragging it into this program, FEAT.
     
  10. Thelostrune

    Thelostrune GBAtemp Advanced Fan

    Member
    546
    128
    Aug 13, 2015
    Norway
    I actually have no idea. It's a two step compression by bch to lz to arc. You'll have to ask gdkchan about this, because he seems to know a lot on this.
     
  11. UnassumingVenusaur
    OP

    UnassumingVenusaur In All Her Gay Glory

    Member
    456
    232
    Nov 20, 2015
    United States
    Well, I know how to compress it as you can see in the screenshots in the OP. I just need to find another way to import the texture into a .bch file, but I didn't expect anyone to have a solution. Thx for your help anyway!
     
  12. Thelostrune

    Thelostrune GBAtemp Advanced Fan

    Member
    546
    128
    Aug 13, 2015
    Norway
    If we knew how, it would solve the problem on my end as well.
    or just .mm/.at support in rebirth when
     
  13. UnassumingVenusaur
    OP

    UnassumingVenusaur In All Her Gay Glory

    Member
    456
    232
    Nov 20, 2015
    United States
    Hmm, do are you asking how I compressed the file? I used BatchLZ77 for the bch (after it compresses, open in a hex editor, copy the first four bytes, paste insert them at the beginning, change the first byte to 13). To turn it back into an arc, paste the .bch.lz in the folder it originally came in, and drag the folder into create.bat from FE If Arc Tool (the folder and create.bat must be in the same directory). Then it's good to go.
     
  14. Thelostrune

    Thelostrune GBAtemp Advanced Fan

    Member
    546
    128
    Aug 13, 2015
    Norway
    No, my problem is that I'm ROM hacking OR/AS and .mm are overworld models and suffer from the same kind of compression issues.
     
  15. UnassumingVenusaur
    OP

    UnassumingVenusaur In All Her Gay Glory

    Member
    456
    232
    Nov 20, 2015
    United States
    Ahhhh okay. Well I'm not experienced with pokemon rom hacking unfortunately.
     
  16. HelpTheWretched

    HelpTheWretched Advanced Member

    Newcomer
    78
    28
    Feb 4, 2010
    Canada
    Hi, UV! I know this thread is about a year and a half old, but I just saw it while searching for something. I had the same issue as you, where importing textures via Ohana3DS (Rebirth) caused ugly compression. Eventually I figured out another way, using a texture converter and a hex editor! If you're still interested, I'll set you up with those. :)
     
    Thelostrune likes this.
  17. DarkSynopsis

    DarkSynopsis GBAtemp Fan

    Member
    410
    242
    Oct 15, 2014
    New Zealand
    New Zealand
    Kukkii in the Kuriimu Suite supports importing textures to .bch files, haven't tested it myself but recall being told it worked better then Ohana in the past.
     
    HelpTheWretched and Thelostrune like this.
  18. Thelostrune

    Thelostrune GBAtemp Advanced Fan

    Member
    546
    128
    Aug 13, 2015
    Norway
    I think we would all like whatever you have.
     
  19. HelpTheWretched

    HelpTheWretched Advanced Member

    Newcomer
    78
    28
    Feb 4, 2010
    Canada
    Well, I jumped the gun and posted that last message before seeing UV's post that said:
    Strangely, my copy of Rebirth does compress the textures when you import them. It's an uncommon release that adds mipmap support, so maybe that's why.

    I've uploaded that version and a couple other programs to this link, since it took a lot of searching to find them and I couldn't tell you where they came from. :P

    bch2png is self-explanatory; drop a BCH file into the app's window, get textures in PNG format. The reason I include it is, it doesn't discard the colour data for pixels that are 100% transparent, like Ohana3DS does. To restore the colour to those pixels, I load the PNG file in GIMP, select Colors -> Curves from the menu, set the "Channel" pull-down menu to "Alpha", then drag the vertex at the bottom-left corner of the graph to the top-left corner.

    3dstex is a command-line program. First you'll need to know the target format of the texture, which Ohana3DS should tell you; probably etc1 or etc1a4.

    Put the edited PNG file in the same folder as 3dstex, open the command prompt to this folder, and type:
    3dstex -r -o etc1a4 -c 3 texture.png texture.raw

    -r makes the output texture raw (no headers/footers)
    -o etc1 / etc1a4 is the output format
    -c 3 is compression level for etc1 textures: 1 is fastest, 3 is best quality.
    texture.png and texture.raw are the input and output filenames.

    Back to the BCH files, make a copy of the BCH you want to edit. In one copy, use that version of Ohana3DS Rebirth to replace the texture that you want to change. It'll get compressed more than you'll like, but that's okay. Now use a file comparison program on the two copies (I used a demo of Beyond Compare 4) to find the hexadecimal adresses of the portion of the file that was changed. These addresses probably end with 00 or 80.

    Once you have those addresses, you'll know exactly what portion of the BCH file to replace with your raw texture file, using a hex editor!

    [Edit]
    Mind you, there will still be some compression in the texture, especially in the reds, especially along edges. But it'll look much better than just replacing the textures with Ohana3DS. I could clearly notice the quality difference in-game between the two methods when I edited some model textures in Tri Force Heroes.
     
    Last edited by HelpTheWretched, Sep 2, 2017
    Thelostrune likes this.
  20. Thelostrune

    Thelostrune GBAtemp Advanced Fan

    Member
    546
    128
    Aug 13, 2015
    Norway
    Oh well, sadly not what I was looking for.