Liar Princess and Blind Prince (Nintendo Switch) - nltx files

Textures, recreate headers, conversions, algorithms and parsing of image files
ChrisX930
Posts: 35
Joined: Wed Feb 24, 2016 11:08 am

Liar Princess and Blind Prince (Nintendo Switch) - nltx files

Post by ChrisX930 »

Hey Guys,

I want to translate a chinese/korean Game for Nintendo Switch.
I'm already able to translate all texts ingame, but I don't have access to the textures yet.

I've uploaded all files inside /romfs/textures folder.
This files are nltx files, most likely containing all the textures of the Game.

Here's the Downloadlink:
https://mega.nz/#!FvxTHC6Y!RikHiRHE3mEs ... XdULKcBMa4

Can someone help me extracting/converting the Textures + reimport them?
iltrof
Posts: 11
Joined: Fri Sep 07, 2018 1:37 pm

Re: Liar Princess and Blind Prince (Nintendo Switch) - nltx files

Post by iltrof »

Here's something that might work.

First off, nltx.bms will convert .nltx to .dds, which you can then edit. Unfortunately, the conversion takes a while. You'll want to keep the result as .dds, because we need uncompressed pixel data, but also because I wrote the reimporter for .dds :P

Now, the next part is a bit tricky. The game uses "YKCMP" compression, which thankfully somebody already reverse-engineered online, but it doesn't have a decent compressor, and writing one seems to be a bit of an investement. We can, however, naively convert .dds back to this YKCMP format, except that the result will not be compressed at all, and in total your textures will take twice as much space.

yk_compress.bms takes .dds files, performs that naive compression and gives you .yk files. Then you have to open the original .nltx file in your favorite hex editor and replace everything after offset 0x80 with the contents of that .yk file. It's also not clear if the game will even accept these naively recompressed files, so I suggest you try it on one texture first, load it into the game and see if it functions.

Good luck!
Last edited by iltrof on Sun Sep 09, 2018 11:00 pm, edited 1 time in total.
ChrisX930
Posts: 35
Joined: Wed Feb 24, 2016 11:08 am

Re: Liar Princess and Blind Prince (Nintendo Switch) - nltx files

Post by ChrisX930 »

iltrof wrote:--snip--

AWESOME JOB!
It works like a charm!
I can extract the dds files, edit them and recompress them with the method you've explained and they work perfectly ingame! <3

Well, I can translate this files now, but I'm still missing textures of the Game.
I thought they would be in the nltx files but it isn't like this.

There's another file format which I've found in the romfs of the game.
I believe they could contain textures.

Do you mind looking into this files?
https://mega.nz/#!cuhW0KwR!OlUvRXAt-bzj ... Yt716OrjrM
iltrof
Posts: 11
Joined: Fri Sep 07, 2018 1:37 pm

Re: Liar Princess and Blind Prince (Nintendo Switch) - nltx files

Post by iltrof »

Glad the reimporting worked! Maybe as a personal challenge I'll even try to implement the actual compression, so that your files' size doesn't explode like that.

As for the .fad files, it seems like they have a lot of specific info in them, and I can't really make sense of it. They do contain a bunch of YKCMP archives though. I extracted some, but if I try to represent them graphically, I just get a bunch of random dots or vertical lines. It appears to me that none of these YKCMP archives contain any textures, and the .fad's don't seem to have any room left to store the textures in any other fashion.

Here's the kind of randomness I'm looking at:
Image

Well, I could be missing something, but you may be out of luck with these .fad's.


Upd: looked at the game files for PS Vita, which only seem to be differently compressed. That doesn't have anything to do with anything though. :P

However, I see that there's a lot of these .fad files, and it doesn't look like the textures could be anywhere else, either. I guess I'll try making a script for extracting all of the YKCMP archives from your files & saving them as .dds. You'll have to look through them manually though. I also don't know where I'd look for the image dimensions, but I'll give it a go, at least.


Upd2: ok, here we go. Excuse the file being an .exe: I felt more comfortable making it in C++ than in bms, and now it's also instant, so you won't have to wait for an extra hour. Just drop it into the folder with .fad's and run it - it will extract every YKCMP it can find into separate folders. For each one you'll get a .dmp with raw contents and a .dds with the squarest image size.

You can also do "fadEx 10000.fad" to just extract one .fad, and "fadEx 10000.fad 7" to only extract the 7th archive from that .fad.

Finally, say, you're scrolling through the .dds'es and you see something that resembles a texture, but its size is incorrect. If, for example, you are looking at /10000/7.dds, you can run "fadEx 10000.fad 7 -a", and it will generate .dds'es of all viable sizes for that texture, placing them in /10000/7/*.dds

I looked through all three of the files you provided, and managed to find one texture, whatever it's supposed to be (#11 in 199995.fad):
Image

So, maybe, you'll be able to find something after all. That just leaves reimporting, and it won't be easy...
ChrisX930
Posts: 35
Joined: Wed Feb 24, 2016 11:08 am

Re: Liar Princess and Blind Prince (Nintendo Switch) - nltx files

Post by ChrisX930 »

iltrof wrote:-snip-

Heyhey

I've tried some of the other fad-files, the dds files are the same as the one you've shown me.
But I really think that this are really textures, I can see something "image like" on these, but obfuscated

Image

Probably something needs to be done with the offset or something?
I'm not that good with graphic types, so :S

I can't find any other files were the ingame textures could be.
There's also romfs/stage, but this are the levels. For textures, the filesizes are way too small.

Probably you know how to "fix" these images?
iltrof
Posts: 11
Joined: Fri Sep 07, 2018 1:37 pm

Re: Liar Princess and Blind Prince (Nintendo Switch) - nltx files

Post by iltrof »

Sorry, I really don't know what to try from this point on :(

I mean, the files do have patterns, so there's likely more to them than I'm seeing, but I just don't know what to do with these patterns.
It doesn't look like the images are chunked - you'd at least see normally connected pixels instead of this colorful mess. They don't really look compressed or encrypted by some conventional algorithm either.
I even tried taking every 4th byte/pixel thinking it would look better, but the result doesn't look any less obfuscated.

So, for now, I have no idea how to "fix" these, if these even are images; maybe somebody else should take a look.
ChrisX930
Posts: 35
Joined: Wed Feb 24, 2016 11:08 am

Re: Liar Princess and Blind Prince (Nintendo Switch) - nltx files

Post by ChrisX930 »

iltrof wrote:-snip-

You're right.
I don't have a clue either :S
Hopefully someone else is able to figure this out ;-;
Thank you for your work anyways! The textures (nltx) work pretty fine ingame after modifiying them :D
That's a big step forward
iltrof
Posts: 11
Joined: Fri Sep 07, 2018 1:37 pm

Re: Liar Princess and Blind Prince (Nintendo Switch) - nltx files

Post by iltrof »

Finally figured out the extraction, I think. Here's the new exe.
Couple of layers of complexity here:

1) fads contain YKCMP archives with textures.
2) The textures are either compressed with bc1_unorm, bc3_unorm, or contain uncompressed RGBA. At least that's true for the three fads you gave me. All three are supported by dds, so we don't need to uncompress the data; we just have to change the dds header accordingly.
3) Furthermore, the textures are swizzled (rearranged). People have already reverse-engineered the algorithm for Switch, so I basically just adapted this code for the final step. In the fads you gave me I saw three different kinds of this swizzling.

Now, before I start working on reimporting, I want you to test that every texture is extracted properly. We don't want to have any surprises later. After all, there might be other compressions/swizzles in the rest of fad files; I can only say it works for the three fads I have.
If the extractor gives an error or just crashes, please give me the fad that broke it - you'll know which one that is.
Even if it doesn't crash, please look at all textures yourself to make sure they aren't weird or anything.

Once again, you can put fadEx.exe in the folder with all fads and just run it - it will extract everything. You can also do "fadEx 10000.fad" to just extract that one fad.
Be aware that fadEx will overwrite results of previous extractions, so copy the textures to some other location before modifying them, just in case.
For reimporting I'm planning to use the same folder structure fadEx uses, and it will also expect the same filenames. So please don't change the filenames :)

Also, I don't know which program you use to modify the dds files, but you might want to check if it preserves the compression. I expect it would, but better be safe ;)
If you open one of the extracted dds files in a hex editor, you will likely see DXT5 at offset 0x54 (meaning it's compressed with bc3_unorm). You can then modify the dds and see if that DXT5 is still there after modification. If it is, everything's good.
(I say "might", but please do check and tell me if the compression stays the same)
ChrisX930
Posts: 35
Joined: Wed Feb 24, 2016 11:08 am

Re: Liar Princess and Blind Prince (Nintendo Switch) - nltx files

Post by ChrisX930 »

Oh shit!
you're a genious!!

It works on all .fad files of the game <3
Preserving the compressions isn't a problem.
The NintendoSDK has a Executable which converts the dds in a dds with a compression I want.
I've sent you a Screenshot of the compression types via PM.


Now I just need a way to rebuild this fad files and we're gold!
We're able to completely mod the game, even the textures we weren't able to translate until now <3

iltrof wrote:-snip-


I've uploaded two dds files.
One of them is the original one, the other one is the translated one.
Both should be DX5 now, same file size. :D
SO editing the files isn't a problem
iltrof
Posts: 11
Joined: Fri Sep 07, 2018 1:37 pm

Re: Liar Princess and Blind Prince (Nintendo Switch) - nltx files

Post by iltrof »

After finishing reimporting, I realised I gave you the wrong fadEx :/
Well, it's not really wrong, but I decided to change the way filenames are generated at the last second and forgot to put it in the archive again.
The new fadEx is in the attachment. Sorry, you'll have to reextract everything. Also, for the textures you've already modified: don't forget to change their filenames as well (just use the names fadEx gives them).

The attachment also contains fadIm, which lets you import .dds back into .fad.
You have two options:
1) Run it like "fadIm 10000.fad -a". Then it will look at every .dds inside the folder called "10000" and import them into 10000.fad. (Doesn't have to be all of the textures. It will keep the original ones inside the .fad if they are not in the folder.)
2) Run it like "fadIm 10000.fad texture.dds". Then it will import that single .dds into the .fad.

Again, as mentioned before, fadIm needs the textures' names to be the same as what fadEx (the new fadEx) generates. fadIm will silently ignore all filenames that look wrong, so don't change them.

Of course, like always, test it and tell me if it works :P
I only know that fadEx will properly extract .fad's generated by fadIm. I can't be sure I'm changing all offsets/sizes properly, so it's up to you to check if the game accepts the new .fad's.

To get you started: take the title screen you translated yesterday and change its name to "0_8_3_4.dds" (this is what the new version of fadEx generates).
Then run "fadIm 10000.fad 0_8_3_4.dds". It will make a new .fad with that modified texture inside.
Try putting it into the game. If it accepts it, then we're golden ;)
ChrisX930
Posts: 35
Joined: Wed Feb 24, 2016 11:08 am

Re: Liar Princess and Blind Prince (Nintendo Switch) - nltx files

Post by ChrisX930 »

iltrof wrote:-snip-

Hell ya, you're the best!!!
I reextracted the 10000.fad and reimported the modified title screen.
The Game doesn't crash, there are no visible bugs aaaaand:

Image

IT WORKS! <3

Gonna post better screenshots tomorrow (it's 11:44pm here, gonna go to sleep now^^)

Thank you soooooo much for this!
gdljjrod
Posts: 1
Joined: Fri Jan 18, 2019 5:34 pm

Re: Liar Princess and Blind Prince (Nintendo Switch) - nltx files

Post by gdljjrod »

Please
You can check files for PSvita.
https://www.dropbox.com/s/4iyqeiluaqngj ... 0.fad?dl=0

im try with your tools but dont work
Unknown swizzle type in
Should be 1, 2 or 3. Skipping...