Gildor's Forums

Author Topic: Mortal Kombat X  (Read 58452 times)
howfie
Newbie
*
Posts: 33


View Profile
Re: Mortal Kombat X
« Reply #60 on: April 24, 2015, 02:19 »

hey howfie! could you please explain what exactly you did with those bone id's xDD

Sure. Now, I only extracted Kitana_A model, so I'll explain that one. In her SkeletalMesh file, the blending information (blend indices and blend weights) are stored at offset 0xB91D4. Reading them is simple:

Code:
 //
 // VERTEX BUFFER #3
 // BLENDING
 //

 struct MKXBLENDWEIGHT {
  uint08 bytes[8];
 };

 // move to vertex buffer
 ifile.seekg(vb3_offset);
 if(ifile.fail()) return error("Seek failure.", __LINE__);

 // read info
 uint16 vb3_h01 = LE_read_uint32(ifile); // bytes per vertex
 uint16 vb3_h02 = LE_read_uint32(ifile); // number of vertices
 uint16 vb3_h03 = LE_read_uint32(ifile); // number of vertices
 if(ifile.fail()) return error("Read failure.", __LINE__);
 if(vb3_h02 != n_verts) return error("Unexpected number of vertices.", __LINE__);
 if(vb3_h03 != n_verts) return error("Unexpected number of vertices.", __LINE__);

 // read data
 boost::shared_array<MKXBLENDWEIGHT> bwlist(new MKXBLENDWEIGHT[n_verts]);
 for(uint32 i = 0; i < n_verts; i++) {
     bwlist[i].bytes[0] = LE_read_uint08(ifile); // blendindex
     bwlist[i].bytes[1] = LE_read_uint08(ifile); // blendindex
     bwlist[i].bytes[2] = LE_read_uint08(ifile); // blendindex
     bwlist[i].bytes[3] = LE_read_uint08(ifile); // blendindex
     bwlist[i].bytes[4] = LE_read_uint08(ifile); // blendindex
     bwlist[i].bytes[5] = LE_read_uint08(ifile); // blendweight
     bwlist[i].bytes[6] = LE_read_uint08(ifile); // blendweight
     bwlist[i].bytes[7] = LE_read_uint08(ifile); // blendweight
     if(ifile.fail()) return error("Read failure.", __LINE__);
    }

First thing to notice is that of the 8 bytes per vertex, 5 of them (not 4) are for blendindices and 3 of them (not 4) are for blendweights. Here is an example:

vtx 0x1bb6: [12 68 90 c1 03] - [7d 38 32] a point on her shirt, near her left boob.

The last 3 numbers: 7D, 38, 32, do not sum to FF so there are 4 blendweights. However, there are 5 indices.

If you view indices as single bytes, you look up 0x12 in the joint map and see it remaps to bone 0x04, which is fine (it's a spine bone). But now you look up 0x68 but can't the joint map only has 0x47 elements in it. chrrox and I noticed that the second number is "almost always divisible by 4." So if you divide 0x68 by 0x04 to get 0x1A and look up 0x1A in the joint map, the second index remaps to bone 0x05, which is also good (another spine bone).

Now try 0x90. The third number is "almost always divisible by 0x10." So we get 0x09 and look it up in the joint map to see it remaps to bone 0xAF, which is a bone in the FOOT! This is wrong, and moving the ankle bone will also move part of her left boob as well lol.

So we know 0x90 is wrong. What is the correct value? Well, in the joint map, her boob bone is bone 0xA3, which is index 0x19. Multiply that index by 0x10 and we get 0x0190. Where do we get that extra 01 from? From the next byte, 0xC1. You get the 1 from the 4 LSB in 0xC1.

Code:
jointmap[0x47] =
00    01    02    03    04    05    06    07    08    09    0A    0B    0C    0D    0E    0F
07 00 06 00 10 00 27 00 28 00 A8 00 A7 00 A9 00 AA 00 AF 00 AE 00 B0 00 B1 00 01 00 02 00 03 00
AB 00 A4 00 04 00 A5 00 AC 00 B5 00 B4 00 B3 00 A2 00 A3 00 05 00 63 00 64 00 82 00 83 00 7B 00
68 00 7C 00 7D 00 7E 00 7F 00 80 00 81 00 75 00 74 00 76 00 71 00 77 00 72 00 73 00 6C 00 6D 00
69 00 6E 00 6A 00 6B 00 78 00 79 00 7A 00 9A 00 87 00 9B 00 9C 00 9D 00 9E 00 9F 00 A0 00 94 00
93 00 95 00 90 00 96 00 91 00 92 00 8B 00 8C 00 88 00 8D 00 89 00 8A 00 97 00 98 00 99 00

So this is what you do for these indices:

[12 68 90 c1 03] hex = [00010010 01101000 10010000 11000001 00000011] binary

Take two LSB from 68 (00) and move them to front of 12 (00010010).
So first index is 0000010010 = 0x12.

Take four LSB from 90 (0000) and move them to front of 68 (01101000).
So second index is 000001101000 = 68 / 04 = 0x1A.

Take 6 LSB from c1 (000001) and move them to front of 90 (10010000).
So third index is 00000110010000 = 190 / 10 = 0x19.

Finally, take all 8 bits from 03 (00000011) and move them to front of c1 (11000001).
So final index is 0000001111000001 = 3C1 / 40 = 0x0F.
0x0F index remaps to bone 0x03, which is also a spine bone and now everything is correct.

I use the following code to process the 5 indices, where i1, i2, i3, i4, and i5 are the original indices:

Code:
     uint16 final_index1 = (i1 | ((i2 & 0x03) << 8));
     uint16 final_index2 = (i2 | ((i3 & 0x0F) << 8)) >> 2;
     uint16 final_index3 = (i3 | ((i4 & 0x3F) << 8)) >> 4;
     uint16 final_index4 = (i4 | (i5 << 8)) >> 6;



« Last Edit: April 24, 2015, 02:21 by howfie » Logged
n0oB_$ayßoaT
Newbie
*
Posts: 3


View Profile
Re: Mortal Kombat X
« Reply #61 on: April 24, 2015, 03:40 »

Hey there. A new guy here. What's up?

The main reason I registered here, perhaps obvious from my username, is to discuss Mortal Kombat X. I've searched the net and went through a few sites and ended up here, because I wanted to ask directly at the source - since Gildor seems to be the Unreal guru. I have a general understanding of things, but never really modified anything Unreal, so please bear with me. Especially since MKX seems to be a somewhat special case.

Now... my intentions... and what I need help with.

What I want to do is translate the game into another language. Ideally 100% of it - meaning subtitles for cutscenes/user interface/menus.

I presume what I'll need to do is locate the appropriate .xxx files (and possibly the .eng file) in the assets folder which contain this data, extract it, modify it (translate) and repack it.

I also presume that not everything is pure text and the interface/menus, etc. might be saved as graphics.

And that's where it kind of ends.

Would UModel suffice for what I want to do or do I need a different tool/method? There was I think some three step .bat alternative?

I imagine this should be much easier than pulling out models/textures, but I may be wrong.

I read the Unreal wiki, but even with that the localization seems a bit tricky.

Thanks!
Logged
Gildor
Administrator
Hero Member
*****
Posts: 7973



View Profile WWW
Re: Mortal Kombat X
« Reply #62 on: April 24, 2015, 10:05 »

Hey there. A new guy here. What's up?
...
Hi.

This forum has a special board relative to localization issues. Probably you'll find anything interesting there.
http://www.gildor.org/smf/index.php/board,22.0.html

By the way, nobody posted easy solutions there, even of somebody found one.
Logged
max_shift
Newbie
*
Posts: 4


View Profile
Re: Mortal Kombat X
« Reply #63 on: April 24, 2015, 13:17 »

hey howfie! my man, thanks a lot. got it work perfectly, a bit bizarre but make sense lol

« Last Edit: April 24, 2015, 13:46 by Gildor » Logged
Gildor
Administrator
Hero Member
*****
Posts: 7973



View Profile WWW
Re: Mortal Kombat X
« Reply #64 on: April 24, 2015, 13:50 »

Well. A few hours of hard work and a little progress: textures are supported now. UModel got a lot of changes in unusual parts of code (where all other games are identical to UE3).

Please read this! All textures are in BC7 format, so they are supported only partially - in viewer. You cannot export them because UModel doesn't have BC7 support. That's caused by NVidia Texture Tools (NVTT) library - it doesn't have BC7 support. Also, neither UE3 nor UE4 supports this texture format.
Logged
UncleFestor
Newbie
*
Posts: 22


View Profile
Re: Mortal Kombat X
« Reply #65 on: April 24, 2015, 14:51 »

I don't know if this will help, but here's Nvidia texture tools BC7 Exporter: https://code.google.com/p/nvidia-texture-tools/downloads/detail?name=bc7_export.zip&can=2&q=

It's supposed to allow decompression & extraction of BC7 Textures
Logged
howfie
Newbie
*
Posts: 33


View Profile
Re: Mortal Kombat X
« Reply #66 on: April 24, 2015, 14:56 »

gildor, if you use that library you can use my code

http://forum.xentax.com/viewtopic.php?p=105556#p105556

to export bc7 to rgba.
Logged
Gildor
Administrator
Hero Member
*****
Posts: 7973



View Profile WWW
Re: Mortal Kombat X
« Reply #67 on: April 24, 2015, 15:27 »

gildor, if you use that library you can use my code

http://forum.xentax.com/viewtopic.php?p=105556#p105556

to export bc7 to rgba.
This code relies on unstable NVTT code - on exactly the same library as in previous UncleFestor's post. NVTT has BC7 support - in svn, but not in "release". The latest NVTT release was, I think, 5 years ago. I tried to integrate updated (unstable) NVTT into UModel, but with no success - this library, just for BC7 support, relies on STL library which can't be used in UModel (that's not taking into account that I hate STL).

There's also DirectXTex library by Microsoft, but it requires DirectX SDK for compilation.

Anyway, BC7 textures are used only in 2 games: Thief 2014 and Mortal Kombat X, so probably it's not worth doing complex integration to allow texture export just for 2 games. These textures could be viewed in UModel if videocard has corresponding OpenGL capability.
Logged
howfie
Newbie
*
Posts: 33


View Profile
Re: Mortal Kombat X
« Reply #68 on: April 24, 2015, 15:52 »

hahahaha I understand gildor. you're right, for just two games when unreal doesn't by default support it, why bother? especially if this requires you to write your own decoder from scratch (i know it's not fun Smiley ).
Logged
Gildor
Administrator
Hero Member
*****
Posts: 7973



View Profile WWW
Re: Mortal Kombat X
« Reply #69 on: April 24, 2015, 16:46 »

Just found another one library - texgenpack. Will check whether it's worth integrating it into UModel because it supports not just BC7, but also ETC2 which is used by Android games.
Logged
TRDaz
Newbie
*
Posts: 14


View Profile
Re: Mortal Kombat X
« Reply #70 on: April 24, 2015, 21:47 »

I tested the new update of Umodel with the files and cannot seem to get the textures to show, they just appear white, is that how they are supposed to be? (as you can't fully support them because of the BC7 format) Umodel gives "unknown texture format 11" error in the cmd.
Logged
Gildor
Administrator
Hero Member
*****
Posts: 7973



View Profile WWW
Re: Mortal Kombat X
« Reply #71 on: April 24, 2015, 23:10 »

It looks like your video card drivers doesn't have BC7 support. I don't remember whether this is DX10 or DX11 feature, but anyway only relatively modern video cards supports that.

UModel tries to upload texture to video card in BC7 format, but fails. It tries to decode texture into RGB format, but there's no BC7 decoder there. So, you have this error message and no texture on screen.
Logged
TRDaz
Newbie
*
Posts: 14


View Profile
Re: Mortal Kombat X
« Reply #72 on: April 24, 2015, 23:16 »

Ah ok, nice work on getting them viewable though, even if it doesn't work for me xD
Logged
Gildor
Administrator
Hero Member
*****
Posts: 7973



View Profile WWW
Re: Mortal Kombat X
« Reply #73 on: April 26, 2015, 02:56 »

I've integrated detex library which should decode BC7 textures, as well as ECT2 (Android format is not supported by anything else).

Bad news. Unfortunately, ETC2 decoding is absolutely unacceptable. BC7 decoding has some glitches - random pixels are noticeably colorized with bad value.
Good news. This library is new, and it is under heavy development, so we could expect fixes to appear in near future.

I'm unsure whether I should enable "detex" code for BC7 in UModel, or wait for fixes or another solution.
Logged
UncleFestor
Newbie
*
Posts: 22


View Profile
Re: Mortal Kombat X
« Reply #74 on: April 26, 2015, 07:33 »

I would say wait. It looks like an active project & they seem to be developing it @ a quick rate, seeing how it's gone through 3 revisions in just 12 days. It would probably be more beneficial to wait for the next update or 2 than implementing it now.
Logged
Jump to:  

Powered by SMF | SMF © 2006-2009, Simple Machines LLC
Leviathan design by Bloc | XHTML | CSS