Tomb Raider Forums  

Go Back   Tomb Raider Forums > Tomb Raider Level Editor and Modding > Tomb Raider Modding

Reply
 
Thread Tools
Old 23-12-15, 06:08   #1
aman11
Member
 
Joined: Oct 2015
Posts: 26
Default Tomb Raider 2013 Texture modding without TexMod

Updated with texture tools:
There is a way to add new textures to TR2013 without using TexMod. The advantage is you don't need to run game in DX9.
I only tested this with the vanilla edition of TR2013 (no DLC). These tools currently only patch character drm that are packaged in patch.000.tiger.
Disclaimer: tools are lightly tested. use at your own risk.

Credit:
Gh0stBlade for sharing tiger and drm file format info and his cdcEngine tools.
Gibbed Tiger unpacker
Ekey's TR9 DRM dumper

Changes:
v1.1 : Fixed a bug in tr9texpatch.cmd script that did not pass correct file name to tr9pcd9patch. Fixed a bug in tr9tigetadd.exe that crashes the game when more than one textures were added to patch.000.tiger file.

Download link: http://www.mediafire.com/download/du...r9texpatch.zip
This package contains 3 executables and one script. User only need to execute tr9texpatch.cmd script, it will call other exectable when needed.
- tr9texpatch.cmd : master script that inject a new cdrm (compressed assets) to patch.000.tiger and patch drm sections inside that tiger file.
- tr9cdrmex : cdrm extractor, take a drm file and section number, extract a compressed cdrm (texure/mesh asset) file.
- tr9pcd9patch : take a (non-compressed) pcd9 texture file and replace its content with content from a dds file.
- tr9tigetadd: append a compressed cdrm file to end of patch.000.tiger and update all cdrm reference to pointer to new cdrm.

Put all 4 files in your Tomb raider 2013 installation folder , same folder as all the bigfile/patch tiger files.

You need following tool from other tool maker:
Gibbed Tiger unpacker and Ekey's TR9 DRM dumper (check this youtube video for guide https://www.youtube.com/watch?v=sR0WOdXIAVU)
Gh0stBlade's TR8 CDRM.exe cdrm compress/decompressor (part of his cdcEnigneTools https://github.com/Gh0stblade/cdcEngineTools/releases)

Copied tiger unpacker and DRM dumper and CDRM.exe to TR game installed directory. Unpack patch.000.tiger by dragging it in windows explorer to Gibbed.TombRaider9.Upack.exe. You will get a new folder called patch.000_unpack, v2_lara.drm is under patch.000_unpack\default\pc-w\v2_lara.drm. Copy v2_lara.drm to TR game installation directory (where all the tiger file located).

run TR9DRMDumper.exe and set the game directory to where your TR is installed. Select File menu/open and locate v2_lara.drm ( from last step). Let tool extract all content. You will find a new v2_lara folder in you TR game directory.

look inside v2_lara\textures\ and find lara's cloth textures. It will help a lot if your windows explorer has DDS thumbnail preview support.

Lara's shirt diffuse map is "Section 419.DDS", normal map "Section 421.DDS", specular map "Section 422.DDS". copy them and modify them
in Paint.NET/GIMP. Do not change the image resolution, save modified textures to DDS with mipmap enabled and the same format as the original
(DXT5 for hair diffuse, DXT1 for almost everything else). Let us assume you saved new DDS as "Section 419x.dds". move "Section 419x.dds" to TR installation directory.

Please make a backup of patch.000.tiger file. If anything goes wrong your can still restore your patch.000.tiger from backup.

To add "Section 419x.dds" to patch.000.tiger and update all drm references to it. First open a command prompt windows,
then do this:

cd <TR9 installation directory>
tr9texpatch.cmd <TR9 installation directory> drm_file section_number dds_file

for example:
tr9texpatch.cmd "C:\Program Files (x86)\Steam\steamapps\common\Tomb Raider" v2_lara.drm 419 "Section 419x.dds"
or
tr9texpatch.cmd . v2_lara.drm 419 "Section 419x.dds"

(file name with spaces must be enclosed inside "", please make sure v2_lara.drm and "Section 419x.dds" are copied to the the same directory as tr9texpatch.cmd)

Now start Tomb raider you should see your new texture appear in game.

---Uninstall texture patch
tr9texpatch.cmd generates a tiger_patch.log file. type this command in command prompt to restore to original texture:

tr9tigeradd <game installation directory> tiger_patch.log
for example:
tr9tigeradd "C:\Program Files (x86)\Steam\steamapps\common\Tomb Raider" tiger_patch.log

== if you install more than one texture patch , you need to change tiger_patch.log to other file name after each patch so you don't lose
the uninstall log for every patch. Uninstall texture in reverse order of the installation.


=== Old post for archiving purpose===
There is a way to add new textures to TR2013 without using TexMod. This method is much more complicated than TexMod and requires a hex editor. The advantage is you don't need to run game in DX9. I only tested this with the vanilla edition of TR2013 (no DLC), this method may need to be updated for different edition of the game. I don't expect people to do all this with Hex editing ,most of these steps could be done by a new mod tool.

You need following tools:
Gibbed Tiger unpacker and Ekey's TR9 DRM dumper (check this youtube video for guide https://www.youtube.com/watch?v=sR0WOdXIAVU)
Gh0stBlade's TR8 CDRM.exe cdrm compress/decompressor (part of his cdcEnigneTools https://github.com/Gh0stblade/cdcEngineTools/releases)
A hex editor (HxD works great for me)

1. You need to already know which character drm you want to change . I want to change Lara's cloth texture after mountain village which is referenced by v2_lara.drm. Game has several tiger files contain v2_lara.drm ( bigfile.001.tiger, title.000.tiger and patch.000.tiger) always pick the one from patchX.XXX.tiger file first as it supersedes others. Also, patch2.000.tiger supersedes patch.000.tiger.

2. I copied tiger unpacker and DRM dumpper and CDRM.exe to my TR game directory. Unpack patch.000.tiger by dragging it in windows explorer to Gibbed.TombRaider9.Upack.exe. You will get a new folder called patch.000_unpack, v2_lara.drm is under patch.000_unpack\default\pc-w\v2_lara.drm

3. run TR9DRMDumper.exe and set the game directory to where your TR is installed. Select File menu/open and locate v2_lara.drm ( from last step). Let tool extract all content. You will find a new v2_lara folder in you TR game directory.

4. look inside v2_lara\textures\ and find lara's cloth textures. It will help a lot if your windows explorer has DDS thumbnail preview support.


Lara's shirt diffuse map is "Section 419.DDS", normal map "Section 421.DDS", specular map "Section 422.DDS". copy them and modify them in Paint.NET/GIMP. Do not change the image resolution, save modified textures to DDS with mipmap enabled and the same format as the original (DXT5 for hair diffuse, DXT1 for almost everything else).

5. Game only work with compressed PCD9 texture format. To convert modified DDS to PCD9, need to combine original PCD9 header with pixel data from DDS file. The section number of original DDS tell us where to find the PCD9 CDRM.
Load v2_lara.drm from step 2 to a Hex editior (HxD). the highlighted numbers below tell us sizes and number of entry in DRM.


6. Bring up your Windows calculator and set it to programmer view and select Hex mode.
To find the offset of a texture, calculate result of " 0x237(red) * 0x14 + 0x0(blue) + 0x0(green) + 0x20 " ==> 0x2c6c ( numbers in color box change from DRM file to file)
Calculate result of ( texture section_no - 1 )*16, convert to hexadecimal and add to above result
for shirt diffuse, we get 0x237 * 0x14 + 0x0 + 0x0 + 0x20 + ( 419 - 1) *16 = offset 0x468c

Hit Ctrl-G key in HxD ,type in 468c which bring cursor to that offset. select and copy 12 bytes from that offset and saving them in notepad for later
" FF 01 00 05 01 08 1C 32 EF 9E 1C 00 "


7. Extract original diffuse texture PCD9 CDRM ( we need its header).
[ FF 01 00 05 01 08 1C 32 EF 9E 1C 00 ]
first 3 bytes are CDRM hash id (00 01 ff)
4th bytes is cdrm type:
05 = texture,
0a = material,
0c = mesh)
5th byte is file name id
01 = bigfile.001,
02 = bigfile.002,
03 = bigfile.003,
00 = title.000 ,
10 = patch.000,
30 = patch2.000
6-8th bytes are offset in file
(08 1c 32 ) == offset (0x321c0800)
if file name refer to bigfile.00?, use offset as-is
if file name is title.000 or patch.000 or patch2.000, subtract 0x400 from offset number before using it.
9th-12th bytes are CDRM size (ef 9e 1c 00 ) = 0x001c9eef = 1875695 bytes.

To extract diffuse CDRM, load bigfile.001.tiger( file id 01) in HxD, hit Ctrl-G and enter offset(321c0800). Cursor moved to begin of CDRM
Right click inside HxD, select "Select Block" , key in 1c9eef as Length which select all data belong to CDRM.


Ctrl-c copy to clipboard.
Select File->new menu to create new tab. ctrl-B paste data to new file, confirm file expansion if asked.
Select File->Save As and save to a new name "diff.cdrm"

8. Decompress diff.cdrm. --> run "CDRM.exe diff.cdrm"

9. if Diff.cdrm still opened inside HxD, HxD will auto-sync the decompressed content, otherwise open Diff.cdrm again manually
file-->open, load modified diffuse DDS from step 4. Hit Ctrl-A to select all content
Right click and pick "Select block" enter hex 80 in start offset. This make selection from 0x80 to end of file.


Ctrl-C , copy selected data to clipboard
click on "Diff.cdrm" tab to switch to diff CDRM. click on bytes at offset 0x1c (image below)


Hit Ctrl-B to paste DDS pixel data ,replacing old pixels. File->Save to save updated diff.cdrm
(If file size grow after pasting, something wrong with new DDS texture. filesize should not grow).

10. Compress diff.cdrm ---> run "CDRM.exe diff.cdrm"
check file size and convert it to a hex number. i.e. 1,861,489 bytes = 0x1C6771
Now we have a new compressed diffuse cdrm ready to be append to patch.000.tiger

11. Make a back up of your patch.000.tiger at this point. there is currently no tool to reverse the mod.

I will add diff.cdrm to patch.000.tiger. Here are the rules:
a) new CDRM must start at file offset 0x?????000 or 0x?????800 ( 2k-byte aligned), if not, in-game tiger file loader will failed.
Use HxD to insert mulitple "0" bytes as padding to end of patch.000.tiger to get correct alignment.
For example, my original patch.000.tiger end at 0x1022ab27, I padding it with 0 to make it end at 0x1022afff. new CDRM start at 0x1022B000.
b) after append new CDRM, append more "0" until file offset end one byte before 0x?????000 or 0x?????800, this means round up new CDRM size to multiple of 2k byes. For example, after appending diff.cdrm , patch.000.tiger end at 0x103f1771, pad with 0 until offset end at 0x103f17ff.
c) add 0x20800 more "0" bytes after you round up the CDRM size, without this additional padding any more CDRM appended after this one will not load correctly. This step also guarantee next CDRM will already be 2k-byte aligned. 0x103f17ff + 0x20800 = file end at 0x10411fff

12. final step: replace all references of shirt diffuse texture with patch.000 id, new cdrm offset and size.
From step 6. original diffuse texture offset reference was
" FF 01 00 05 01 08 1C 32 EF 9E 1C 00 "
From step 10, new texture cdrm size is 0x1c6771
From steo 11, new 2k aligned texture added to patch.000.tiger starting at offset 0x1022B000 , need to add 0x400 to it. make it 0x1022B400
New diffuse texture table entry will change to:
" FF 01 00 05 10 B4 22 10 71 67 1c 00 "
first 4 bytes unchanged,
5th byte--> "10" --> refer to patch.000.tiger file
6th-8th byte --> CDRM offset 10 22 B4 00 , drop last "00", reverse the byte order (little endian).
last 4 bytes --> CDRM size 00 1c 67 71, in little endian order.
Load patch.000.tiger to HxD
Hit Ctrl-R (search and replace)
put "FF 01 00 05 01 08 1C 32 EF 9E 1C 00" in search for box
put "FF 01 00 05 10 B4 22 10 71 67 1c 00" in replace with box
change datatype to "hex-values"
click "replace all" button, you should get a message like "Replace 13 occurrences of ..."
Save changes of patch.000.tiger

Launch game and check whether it run and new diffuse texture shows up for Lara after mountain village and at the snow peak radio tower.


13. Repeat step 6 to 12 for normal and specular texture. they have their own section no.

Last edited by aman11; 10-09-16 at 00:17. Reason: Add texture patching tool link and instrtuctions
aman11 is offline   Reply With Quote
Old 06-09-16, 16:42   #2
aman11
Member
 
Joined: Oct 2015
Posts: 26
Default

Added texture patch tool link and instructions to first post.
aman11 is offline   Reply With Quote
Old 06-09-16, 17:16   #3
VictorXD
Member
 
VictorXD's Avatar
 
Joined: Jan 2009
Posts: 9,827
Default

Nice, I'd use this if I had a good enough PC to run TR with TressFX BTW, are you the same aman that made the blender imoprt/export for RE?
VictorXD is offline   Reply With Quote
Old 06-09-16, 17:31   #4
aman11
Member
 
Joined: Oct 2015
Posts: 26
Default

Quote:
Originally Posted by VictorXD View Post
Nice, I'd use this if I had a good enough PC to run TR with TressFX BTW, are you the same aman that made the blender imoprt/export for RE?
I am the same Aman that made the RE6 import/export blender plugins.
aman11 is offline   Reply With Quote
Old 06-09-16, 17:38   #5
VictorXD
Member
 
VictorXD's Avatar
 
Joined: Jan 2009
Posts: 9,827
Default

Cool! Keep up the awesome work on both franchises
VictorXD is offline   Reply With Quote
Old 07-09-16, 13:40   #6
aman11
Member
 
Joined: Oct 2015
Posts: 26
Default

Quote:
Originally Posted by VictorXD View Post
Cool! Keep up the awesome work on both franchises
Thank you. I made a TR2013 character mesh import/export blender plugins some time ago. Maybe I will release it after this cdrm assets injection process is proven to work.
aman11 is offline   Reply With Quote
Old 09-12-18, 20:23   #7
Anatoly
Member
 
Joined: Nov 2018
Posts: 4
Default

Hello!
Thank you for the lesson. I can already change the textures in the game. But there is a problem with exporting to Blender.
The problem is this: I cannot export model to TR9 (* mesh) format.
Blender generates an error in (io_TR9_mod_tool_v0_4.py) when exporting a model to the TR9 format (* mesh).
--------------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\ARCHIMED\AppData\Roaming\Blender Foundation\BIender\2.76\scripts\addons\io_TR9
mod_tool_vO_4.py". line 2218, in execute exported = do_export(self, context, props, filepath, bSmoothOverlapVertex)
File "C:\Users\ARCHIMED\AppData\Roaming\Blender Foundation\Blender\2.76\scripts\addons
\io_TR9_mod_tool_vO_4.py", line 1087, in do export f = open(filepath,'rb')
FileNotFoundError: |Errno 2) No such file or directory: 'E\\A_new_Lara\\Work\\BIenderwork\\Lara_cor_v4.dae .mesh'
location: <unknown location>:-l

--------------------------------------------------------------------------
Anatoly is offline   Reply With Quote
Old 13-12-18, 08:24   #8
Heartache
Member
 
Heartache's Avatar
 
Joined: Dec 2008
Posts: 3,424
Default

okay why has no one yet made pop ups invisible and removed the white paint? where you at talented people?
Heartache is online now   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 21:49.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Tomb Raider Forums is not owned or operated by CDE Entertainment Ltd.
Lara Croft and Tomb Raider are trademarks of CDE Entertainment Ltd.