Hacking [release] BFLIM Extractor

AboodXD

I hack NSMB games, and other shiz.
OP
Member
Joined
Oct 11, 2014
Messages
2,871
Trophies
1
Location
Not under a rock.
XP
2,868
Country
United Arab Emirates
BFLIM Extractor v2.1

BFLIM Extractor is a tool for extracting and creating .bflim files used for layouts' textures in some of the Wii U games.

Supported texture formats:
  • GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM (ABGR8 / BGR8)
  • GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_SRGB (ABGR8 SRGB / BGR8 SRGB)
  • GX2_SURFACE_FORMAT_TCS_R10_G10_B10_A2_UNORM (A2RGB10)
  • GX2_SURFACE_FORMAT_TCS_R5_G6_B5_UNORM (RGB565)
  • GX2_SURFACE_FORMAT_TC_R5_G5_B5_A1_UNORM (A1RGB5)
  • GX2_SURFACE_FORMAT_TC_R4_G4_B4_A4_UNORM (ARGB4)
  • GX2_SURFACE_FORMAT_TC_R8_UNORM (L8 / A8)
  • GX2_SURFACE_FORMAT_TC_R8_G8_UNORM (A8L8)
  • GX2_SURFACE_FORMAT_TC_R4_G4_UNORM (A4L4)
  • GX2_SURFACE_FORMAT_T_BC1_UNORM (BC1 / DXT1 / ETC1)
  • GX2_SURFACE_FORMAT_T_BC1_SRGB (BC1 SRGB / DXT1 SRGB)
  • GX2_SURFACE_FORMAT_T_BC2_UNORM (BC2 / DXT3)
  • GX2_SURFACE_FORMAT_T_BC2_SRGB (BC2 SRGB / DXT3 SRGB)
  • GX2_SURFACE_FORMAT_T_BC3_UNORM (BC3 / DXT5)
  • GX2_SURFACE_FORMAT_T_BC3_SRGB (BC3 SRGB / DXT5 SRGB)
  • GX2_SURFACE_FORMAT_T_BC4_UNORM (BC4L / BC4A)
  • GX2_SURFACE_FORMAT_T_BC5_UNORM (BC5)
Treeki said:
Why so complex?
Wii U textures appear to be packed using a complex 'texture swizzling' algorithm, presumably for faster access.

Download.
Source code / Github.
 
Last edited by AboodXD,

Ray Koopa

Obviously a Koopaling
Member
Joined
Aug 18, 2015
Messages
332
Trophies
0
XP
289
Country
Batch is your friend (converts all BFLIM files in Convert folder):
Code:
@ECHO OFF
FOR %%f IN (Convert/*.bflim) DO (
    ECHO Converting: .\Convert\%%f
    BFLIM_EXTRACT Convert/%%f
)

Suggestions:
- Please don't wait 5 seconds to display errors. Horrible in a batch process. Maybe just do that if started without any parameters to make users just clicking the exe see it.
- Support output path
- Don't open input files with write access (errors out when read-only flag set)

I like your effort. Format 0x10 and 0xF is heavily used in MK8, looking forward for support. Sadly, the other formats are not unswizzled correctly most of the time.
errors.png
 
Last edited by Ray Koopa,

EpicLPer

Nice unless you give me a reason to hate you ;)
Member
Joined
Mar 13, 2015
Messages
1,060
Trophies
0
Age
27
Location
Austria
Website
epiclper.com
XP
1,126
Country
Austria
Batch is your friend (converts all BFLIM files in Convert folder):
Code:
@ECHO OFF
FOR %%f IN (Convert/*.bflim) DO (
    ECHO Converting: .\Convert\%%f
    BFLIM_EXTRACT Convert/%%f
)

Suggestions:
- Please don't wait 5 seconds to display errors. Horrible in a batch process. Maybe just do that if started without any parameters to make users just clicking the exe see it.
- Support output path
- Don't open input files with write access (errors out when read-only flag set)

I like your effort. Format 0x10 and 0xF is heavily used in MK8, looking forward for support. Sadly, the other formats are not unswizzled correctly most of the time.
errors.png
Suggestion: Add a /nowait option or something, also a /folder maybe to make it easier ;)

But it's still early so yeah, we'll see :D

PS.: Oh boy I'm so hyped for all the dick texture replacements people will come up with then lol (sarcasm)
 
  • Like
Reactions: TotalInsanity4

Ray Koopa

Obviously a Koopaling
Member
Joined
Aug 18, 2015
Messages
332
Trophies
0
XP
289
Country
NOWAIT? You stole that name from Commander Keen right? :P
Anyway, don't do that, a command line tool should never wait needlessy, so handle it cleverly just when displaying help.
 

AboodXD

I hack NSMB games, and other shiz.
OP
Member
Joined
Oct 11, 2014
Messages
2,871
Trophies
1
Location
Not under a rock.
XP
2,868
Country
United Arab Emirates
All your requests are too easy to implement. :P

@EpicLPer Use:
Code:
for %%f in (Path/*.bflim) do bflim_extract Path/%%f

Files which end with ^l are RGBA32 files, those are 100% tested and they work perfectly.
Files which end with ^o, ^p, or ^q are BC compressed, those are 100% tested, for some odd reason the output image gets cut in half... :/

Everything else isn't supported, and will be soon.
 
Last edited by AboodXD,

Spidey_BR

Well-Known Member
Member
Joined
Feb 1, 2008
Messages
211
Trophies
0
XP
821
Country
Netherlands
Nice work. Too bad my Python skills are ridiculous at best. I was hoping to fork and implement the requested changes right away (no sleep, error code semantics) just as a practice section.

What are the references on these file formats?
 

AboodXD

I hack NSMB games, and other shiz.
OP
Member
Joined
Oct 11, 2014
Messages
2,871
Trophies
1
Location
Not under a rock.
XP
2,868
Country
United Arab Emirates
I've already made a documentation of the GFD (A very similar format to BFLIM, they're both used on Wii U) File format, you can find it here:
https://github.com/aboood40091/GTX-Extractor/wiki

It's a bit incomplete but that doesn't matter that much. :P

I can still make a documentation of the BFLIM File format if you want.

Please note that both GFD and BFLIM formats are very complex.
 
Last edited by AboodXD,

Ray Koopa

Obviously a Koopaling
Member
Joined
Aug 18, 2015
Messages
332
Trophies
0
XP
289
Country
For me it's just the bugs I posted in my previous post, if you want =3
- Don't wait 5 seconds
- Don't open input files with write access
- Look at the other format which completely throws up due to wrong swizzling (the greenish blocks)
 

Ray Koopa

Obviously a Koopaling
Member
Joined
Aug 18, 2015
Messages
332
Trophies
0
XP
289
Country
If you call open, don't pass 'w'. That makes the program crash being incapable to open files with a read-only flag. Just open them with 'rb'. I send you the files as a PM
 
General chit-chat
Help Users
  • No one is chatting at the moment.
    KenniesNewName @ KenniesNewName: Wee wee