How to muck about with Far Cry 4 textures a bit

Started by JRavens, August 28, 2015, 06:52:56 AM

Previous topic - Next topic

0 Members and 6 Guests are viewing this topic.

JRavens

This is a kind of mini-tutorial if you will about Far Cry 4 textures. It also applies to Far Cry 3 as well. Both games use the same formats, etc.

Mostly written for GKID7891, but figured anyone might be interested in it.

NOTE - this ended up being really long (sorry!) and it probably involves a lot of terminology you may not be familiar with. Don't be scared off. It might take several readings and you may even need to have it printed off or minimized on your screen so you can jump back to it. I'm also assuming readers will have access to the Far Cry files. So you'll need to be able to have the basics of unpacking files, etc. I making the assumption you have and can use Gibbed's Dunia 2 Tools and that you have Janne252 archetype files. If you don't have those or can't figure them out you will most likely not be able to do anything with this tutorial... so I guess this is kind of "advanced" stuff for Far Cry modding. If you've modified weapons before like changed their damage or range, etc. you will probably be fine. If you've never modded Far Cry before you will probably be sooo lost reading this LOL. :D Come back to it when you get some more modding under your belt and feel more comfortable with where all the files are at, etc.  8)

First about the textures themselves (skip if not interested in trying to alter a texture in photoshop):

Far Cry 4 uses .dds textures which are converted into their own propitiatory format .xbt

So here's an example name of a file from the AK-47:
\graphics\_common\_textures\weapons\ak74m\ak74m_04_d.xbt

You need a tool to convert .xbt to .dds and back if you want to actually be able to change the textures. I won't cover all of that here, but google "xbt to dds convertor" to chase down (hopefully) still working links to a tool to do this. Of course this is only if you actually want to try and modify how the textures look. A little further down I'll get into swapping them around.

Nvidia has free plugins for photoshop that allow working with dds files you can download. Not sure if there are plugins for other programs like GIMP, etc.

Now there are often 3 "kinds" of texture files used by Far Cry with names ending in = _d.xbt _n.xbt _m.xbt

_d.xbt are detail textures. These are the actual textures themselves with all the little details. This is most likely the only textures you would be changing.

_n.xbt are normal map textures. These give the texture a 3 dimensional look by adding well "texture" to it so a cloth will have little bumps and groves that make it look like cotten or wool and rusty metal will have protruding edges, rivets will bump out away from the texture and so on.

_m.xbt I think are environment maps. My (very limited) understanding is they define how the surface of the texture interacts with the lighting so you can have shiny metal objects, or dull dusty objects, or soft skin, etc. To be honest my knowledge of how these files w@&k precisely and what colors to use on them is very basic so I tend to avoid trying to mess with them as I get unpredictable results.

Look again at the AK-47 here are some of the files it has:
\graphics\_common\_textures\weapons\ak74m\ak74m_04_d.xbt
\graphics\_common\_textures\weapons\ak74m\ak74m_04_m.xbt
\graphics\_common\_textures\weapons\ak74m\ak74m_04_n.xbt

Many textures will have 2 versions = blahblahtextures_d.xbt and blahblahtexture_d_mip0.xbt

Back to our AK-47 example:
ak74m_04_d.xbt
ak74m_04_d_mip0.xbt

Texture _d does not need mipmaps
Texture_d_mip0 DOES have mipmaps (mipmaps are a series of progressively smaller textures that are swapped out as you get closer or further away from an object)

If you alter the DDS files when exporting I always choose this option from the Nvidia export dialog box:
DXT 5    ARGB  8 bpp | interpolated alpha

And then I select Generate MIP Maps if it's a _mip0 file or "No MIP Maps" if it's not.

OK so that's the basic run down on the types and uses of the textures. Lets look at how Far Cry applies them to the models:

Each objects (weapon, enemy, animal, object, etc.) has an entity archetype file (filename.ark.fcb) that sits in the folder  \entityarchetypeslibrary\.
Our example AK47 has multiple ones, but the one that defines the players AK47 and what skins it has is:
\entityarchetypeslibrary\216180365620235801.ark.fcb

Inside of those files is where where Far Cry assigns what it calls "materials". Materials are .bin (binary?) files found in \graphics\_materials\

Each .bin file will designate multiple texture files and in various layers as well as define other information like any shaders to apply, etc. So a material bin file could add a layer of say wood grain by adding a wood texture or make a texture look like shiny gold or chrome.

So lets grab an entry from a line in the AK47 entity file:
field hash="F792AA50" type="String">graphics\_materials\grassam-m-64201451096718.material.bin

OK so if we go grab grassam-m-64201451096718.material.bin file and open it in a hex editor we seea  bunch of junk like this:
Metal_ANISO.(....Metal.....*..~#^...Q`4Xw.8graphics\_common\_textures\weapons\ak74m\ak74m_04_d.xbt.....*..~#^..)X.4Xw.8graphics\_common\_textures\weapons\ak74m\ak74m_03_n.xbt.....*..~#^..<.&4Xw.8graphics\_common\_textures\weapons\ak74m\ak74m_04_m.xbt

Now we can guess this is the metal parts of the AK and it showing us in this particular material file it uses 04_d.xbt for the main texture with 03_n.xbt for all the bumps and grooves of the parts and 04_m.xbt for the shiny.

An important part of these material files is that they also contain shader and coloring information.

I'm sure you've probably seen some Royal Army (and some pirates in FC3) have red pants or red bandannas on their heads and so forth. Well those textures are not actually red. Instead usually the material  .bin file changes the textures to show up red in the game.

I don't know how to write new material bin files or even convert the ones that are in the game so all I can advise on is using a hex editor to change what is currently there.

So lets say you want to make a GOLD Famas (aka the F1 in the Far Cry games)

Well the first thing you would need to do is look at the AK47 and try to find in it's entity archetype file where the GOLD skin is defined. Taking a look at that file there is a section of material bin files under the section called Skinlist. This section has multiple sub entries (one for each como that you can buy for the gun and in this case it also has an additional entry that is used for the Warrior signature AK47).

Now I'm not 100% sure, but if I had to guess the skin labelled Var6 is most likely the GOLD AK skin. I say this because I think in the shop that the Gold Skin is the last skin or #6 skin on the shop list. This may not mean anything and it could be that the skins are juggled up a bit.

EDIT - I was wrong and they are juggled up. So I found a way to figure out which was which. Each weapon skin has a variable like this = field name="locSkinNameId" type="Int32">167202</field
That number (167202) points to a string in the oasis file which tells you which paint job it is by name (NOTE changing these numbers won't actually change the paint job only it's name). So for reference:

id="167196" value="BLACK"
id="167197" value="RED"
id="167198" value="GRANITE"
id="167199" value="PURPLE"
id="167200" value="DRY LANDS"
id="167201" value="GOLD"
id="167202" value="CLASSIC"
id="167203" value="VINTAGE"
id="167204" value="STALKER"
id="167205" value="GREEN"
id="167206" value="FIERCE"
id="167207" value="SILVER"
id="167208" value="PREDATOR"
id="167209" value="MODERN"
id="167210" value="BUSHMAN"
id="167211" value="WHITE"
id="167212" value="HUNTSMAN"
id="167213" value="PRIMAL"
id="167214" value="AQUA"

So it turns out that the skin var1 is the gold skin. So that is the entries you would want to look at.

I'll take the first entry under Var1 skin:
field hash="F792AA50" type="String">graphics\_materials\grassam-m-64201451096718.material.bin</field
field hash="8BBC37A1" type="BinHex">504C2F8C57477A06</field
field name="text_matMaterial" type="String">graphics\_materials\grassam-m-20140605100144.material.bin</field

The top material should be the regular AK47 material and the bottom one is the one it swaps to when you apply this skin. I'm not sure THIS exact one is the one that gives the gold shine to the metal. You would have to check all of them to figure out which is which but for the sake of this tutorial lets say that grassam-m-20140605100144.material.bin makes the metal parts of the AK47 shiny gold.

To apply that effect to the F1 you would make a COPY of the grassam-m-20140605100144.material.bin file and rename it something like F1GOLDMETAL.material.bin
Always w@&k with copies so you don't mess up the orginal files.

Then you just need to look at the F1 files and find the texture names and so forth. Poking around where I found the AK47 textures (\graphics\_common\_textures\weapons\ak74m) I find the F1 weapon textures in \graphics\_common\_textures\weapons\famas.

If we open our F1GOLDMETAL.material.bin file in a hex editor and we are VERY careful we can change some of the file paths and names to point to the F1 files instead of the AK74 files.

Changing these bits:
graphics\_common\_textures\weapons\ak74m\ak74m_04_d.xbt.....*..~#^..)X.4Xw.8graphics\_common\_textures\weapons\ak74m\ak74m_03_n.xbt.....*..~#^..<.&4Xw.8graphics\_common\_textures\weapons\ak74m\ak74m_04_m.xbt

to this:
graphics\_common\_textures\weapons\famas\famas_d.xbt.....*..~#^..)X.4Xw.8graphics\_common\_textures\weapons\famas\famas_n.xbt.....*..~#^..<.&4Xw.8graphics\_common\_textures\weapons\famas\famas_m.xbt

You can see though that this changes the file length some because famas_d is shorter than ak74m_04_d so sometimes this causes problems and also some hex editors aren't the easiest in the world to change bytes around with. If you can't make it w@&k using the above method than a w@&k around would be to (again VERY carefully) alter the original bytes to something like this:

graphics\_common\_textures\weapons\ak74m\ak74m_F1_d.xbt.....*..~#^..)X.4Xw.8graphics\_common\_textures\weapons\ak74m\ak74m_F1_n.xbt.....*..~#^..<.&4Xw.8graphics\_common\_textures\weapons\ak74m\ak74m_F1_m.xbt

Now you are keeping the file length the same and just changing a few 03 and 04s to F1. If you do it this way  though you have to make copies of the F1 texture files and rename them to those names and stick them in the ak47 filepath so the game can read the files.

Once you have your copy of the F1GOLDMETAL.material.bin hex edited so the game pulls the F1 textures instead of the AK47 textures you have to go into the F1 entity file and change whatever entry to look for this new material bin file you created.

So for example I looked up the F1 entity file ( \entityarchetypeslibrary\7656527669248.ark.fcb) and looked at it's var1 skin (which btw apparently is the STALKER skin according to it having a locSkinNameId of 167204)

And poking around in there I find this line is the likely suspect to change to affect the main metal of the F1:

field name="text_matMaterial" type="String">graphics\_materials\jzhang2-m-20140731184821.material.bin</field

So you would change it to your new copy:
field name="text_matMaterial" type="String">graphics\_materials\F1GOLDMETAL.material.bin</field

Now with any luck that actually does *SOMETHING* to the Famas metal and with a LOT of luck it actually changes the metal gold (I didn't test it because just this tutorial took forever to write up - sorry it's such a wall of confusing text)

Any way that's the basics of where the game finds and applies textures for objects.

Actually MAKING changes is a bit tedious (as you can see from the tutorial) and requires a LOT of testing and tweaking.

Hopefully someone finds this useful. I have used this method and ones similar in the past to change skin textures for animals and vehicles so it should w@&k although you may need to experiment a bit to fully understand and make use of the process. No amount of text in the world can replace real hands on training so you will learn wayyy more simply by trying to apply these techniques than just reading about them. This primer however will point you in the right directions.

Thanks :)
And all this science, I don't understand...
It's just my job, five days a week

Paul J

Thanks JR: My "Fac Cry 4 Notes" doc is now 45 pages long... most of it coming from you. Cheesh!

pj
I took an IQ test and the result was negative...

OWGKID

LEGACY

JRavens

Quote from: Paul J on August 28, 2015, 09:49:19 AM
Thanks JR: My "Fac Cry 4 Notes" doc is now 45 pages long... most of it coming from you. Cheesh!

pj

Heya pj! You made it over here too I see ;)

Probably should look it over and clean it up a bit since I wrote it off the cuff while trying to answer GKID's request about making a "Golden Guns" mod.

I'll also repost this as well on the other forums tutorials section when I get a chance.
And all this science, I don't understand...
It's just my job, five days a week

PZ

Never worry about how you post things here at OWG - the information is most appreciated

+1  :-X

Welcome to OWG, Paul J  ;)

Art Blade

Hello PJ, welcome to OWG :)

And JR (ahem, nothing to do with that soap opera character I suppose) nice tutorial +1 :-X :)
[titlebar]Vision without action is a daydream. Action without vision is a nightmare.[/titlebar]What doesn't kill us, makes us weirder.

Paul J

Thank you, Gentlemen! It's a pleasure to find some more like-minded folk out there!  :-X

The old site was getting boring, with it's 2 colours (light blue and white), and having to continually pay JRaven's weekly tithe - it was starting to drain the bank... He's a harsh task master too... bad tempered.. "Do this" "Do that" and so on..  8)

pj
I took an IQ test and the result was negative...

OWGKID

LEGACY

Paul J

I took an IQ test and the result was negative...

mandru

Quote from: Paul J on August 29, 2015, 02:02:07 AM

The old site was getting boring, with it's 2 colours (light blue and white)...



On the Home Page (the right column) there is a drop down menu that will you to further set the site's color scheme to suit your preferences.  :-X
- mandru
Gramma said "Never turn your back 'till you've cut their heads off"

Paul J

 :-X  Will try 'em all Mandru. It's just like a new car isn't it!   :-()
I took an IQ test and the result was negative...

Art Blade

[titlebar]Vision without action is a daydream. Action without vision is a nightmare.[/titlebar]What doesn't kill us, makes us weirder.

mandru

- mandru
Gramma said "Never turn your back 'till you've cut their heads off"

JRavens

Quote from: Paul J on August 29, 2015, 02:02:07 AM
Thank you, Gentlemen! It's a pleasure to find some more like-minded folk out there!  :-X

The old site was getting boring, with it's 2 colours (light blue and white), and having to continually pay JRaven's weekly tithe - it was starting to drain the bank... He's a harsh task master too... bad tempered.. "Do this" "Do that" and so on..  8)

pj

LIES! I am a fair and benevolent master. Now no bread for you and 30 lashes!  >:D
And all this science, I don't understand...
It's just my job, five days a week

PZ


Paul J

It's like fishing in a barrel isn't it...   :angel:
I took an IQ test and the result was negative...

Art Blade

that.. sparks an idea.

Here, JR, have a couple of sticks of dynamite  :-()



Uh-oh.  ???

<runs away screaming while dodging objects thrown by PJ>
[titlebar]Vision without action is a daydream. Action without vision is a nightmare.[/titlebar]What doesn't kill us, makes us weirder.

JRavens

Quote from: Art Blade on August 30, 2015, 08:20:57 AM
that.. sparks an idea.

Here, JR, have a couple of sticks of dynamite  :-()



Uh-oh.  ???

<runs away screaming while dodging objects thrown by PJ>

You joke Art Blade, but I toss bombs at him all the time ("Wait Jeff you were supposed to tell me how this and this works not send me a file about how to spawn flying buses driven by macaques!?")

Hmmm... actually Buses driven by Monkeys? GENIUS! I'll see you guys later! <runs off to computer>
And all this science, I don't understand...
It's just my job, five days a week

Art Blade

 ^-^

by the way guys, just call me Art. Less typing :)
[titlebar]Vision without action is a daydream. Action without vision is a nightmare.[/titlebar]What doesn't kill us, makes us weirder.

JRavens

Quote from: Art Blade on August 30, 2015, 08:33:07 AM
^-^

by the way guys, just call me Art. Less typing :)

You got it Art!

You guys can me whatever (just not late for dinner yuk yuk ... oh that was awful  8-X)
And all this science, I don't understand...
It's just my job, five days a week

PZ

You guys fit in perfectly around here, JR and PJ!  :-X

Nice new avatar, AB  ^-^

Art Blade

[titlebar]Vision without action is a daydream. Action without vision is a nightmare.[/titlebar]What doesn't kill us, makes us weirder.

Paul J

Quote from: PZ on August 30, 2015, 08:50:37 AM
You guys fit in perfectly around here, JR and PJ!  :-X

Isn't that funny... my wife said that to me a while ago... didn't mention JR, though, thank (whoever)
I took an IQ test and the result was negative...

JRavens

And all this science, I don't understand...
It's just my job, five days a week

Art Blade

[titlebar]Vision without action is a daydream. Action without vision is a nightmare.[/titlebar]What doesn't kill us, makes us weirder.

Tags:
🡱 🡳