Cyberpunk 2077: Using custom Textures on imported Meshes

This is not a complete beginner's guide. You are expected to have worked with the tools used in this tutorial before.

 

The main porting part will be covered my someone else and linked here eventually. This only explains how to set up your custom standard PBR textures to use them on imported meshes instead of the game's Multilayer shading system.

 

Everything here is based on alphaZomega's guide in the modding server. You can check it out here, however my guide uses a different material buffer that does not have skin shading.

 

Prerequisites:
- 010 Editor and the Cyberpunk template and scripts

- My Material buffer from here
Wolvenkit.cli (Wolvenkit Console)

Why this Buffer and not the Skin one?

The skin buffer will always have skin shading effect, even when you mask it out. You will on default also get the skin detail normal all over your mesh which makes everything sort of look like leather. You can turn this off inside the buffer, but the color and general SSS shading remains.

 

The picture below shows the difference between skin.mt (left) and metal.remt (right) based buffer. Model and textures used are the same. Dark colors will end up with a blueish tint, even when textures are 100% desaturated and you can see metal.remt one looks closer to other clothes in the game.


1. Preparing the mesh to convert the Port with

The mesh you choose to swap the buffer in should have all the bones your ported model needs. For eg. if you convert a top like the one above, you should use a game mesh that also has this neck part. 

 

For this example, I will use:               
garment\player_equipment\torso\t0_005_pma_body__t_bug\t0_005_pwa_body__t_bug.mesh

 

The first thing you need to do is get this mesh's buffers into their own files. There is a way to directly edit in 010 somehow but I never did that.

To uncook meshes with buffers, use this command in Wolvenkit.cli on an archive:

wolvenkit.cli uncook -fb mesh -p "your archive path here"

 

These are the files you should have for this mesh:


The material buffer (if it exists) is always the second to last. So in this case it's .12. Copy its name and then delete this file. Replace it with the buffer you downloaded from me above. Name that buffer t0_005_pwa_body__t_bug.mesh.12.buffer. Now when rebuilding, the model will use this instead, but don't do that just yet.

2. Material Sizes and Offsets in 010

Now open t0_005_pwa_body__t_bug.mesh in 010 and run the cyberpunk main script on it. Navigate to the pictured section, be careful to follow it exactly before reporting problems. Naming in these sections can be repetitive and confusing due to similarity.

 

Colorised on the next image are the different material entries. Each of these accesses their respectively set material inside the material buffer.


If you expand the first two entries, you can see the offsets and sizes. 

This is how the mesh knows which material is where inside the buffer. The first entry has no Offset, because the offset would be 0 as it is the start of the mat buffer file. The size is the length inside that file. The next material has the length of the previous one as its offset, which simply means it starts directly where the previous one ends. 

The third entry starts at offset 1811. This is the sizes of the first two entries combined. You can utilize this to stack your own entries inside the buffer, which is done by simply pasting the seperate ones one after another in hex while keeping record of their individual sizes.

 

In this tutorial however, I use a buffer that has only one material inside, so don't worry about that stuff.

 

You need to know the size (in bytes) of your buffer entry. Since this buffer only has one entry, the entire file counts. The easiest way to check the size is to right click it and check this value in 'Properties':

Since the entry is the entire file, the offset will be 0 and the size will be 1024. For safety, run CP77_CR2W_changeMatHdrs.1sc in 010 with 1024 as the input value. This will automatically change all materials to offset 0 and size 1024.

 

In this case, you are done here and can save the mesh.

3. Adding your Textures to the Buffer

The buffer provided expects 4 textures:
- Diffuse/Albedo/Color (can include an Alpha channel for transparency)
- Normal
- Roughness

- Metalness


If you are not familiar with some of them, check this introduction to PBR textures.

A texture set to export over is available here if you need.

 

Open t0_005_pwa_body__t_bug.mesh.12.buffer in 010 and navigate here. Marked red are the texture paths inside the game files (you need to set this up inside your mod folder).

Don't make your paths too long. Names in this buffer can be 71 bytes long or shorter, but not longer (unless you do it in wkit). Simply make any folder after 'base' and put your textures there, then replace the paths of the right texture type. The order is:
- Diffuse/Albedo/Color
- Metalness
- Normal
- Roughness

 

Once you have done it, save the file.

4. Rebuilding the Mesh and Player mesh Caution

Enter this command in Wolvenkit.cli to rebuild the mesh:

 

wolvenkit.cli import -k -p "path to your mesh's folder"

 

The .mesh file will now be rebuild and can be packed with the rest of your mod.

 

 

IMPORTANT NOTE FOR PLAYER MESHES:

 

If you weren't aware before, player meshes will in 99% of cases crash when mesh edited. This is because the garment morph system is not supported by current tools. You can prevent crashes using the following method.

 

!!!Do this only on the final mesh that you import! Don't do this on the model you use for converting. Once you do this the mesh becomes UNREADABLE by any tools, which means you can't export nor convert with it anymore. I recommend making a backup always!!!

 

Open your final mesh file in 010 with the template. Run CP77_CR2W_Erase.1sc on these two entries:

The result should look like this:

Save this and it will not crash the game anymore, but as mentioned, it cannot be exported nor used for conversion anymore!


I hope you found this guide useful! If I learn new methods I will adjust it :)

 

Happy Modding!

- xBaebsae