moxxy wrote:Does anybody know how textures are referenced in material files and materials in mesh files respectively?
I extracted the asset names from the .tr2pcd files, hashed them and brute forced the material files for values containing the hashed
name. Unfortunately it didn't yield any match.
For example:
Code: Select all
// Repeat for every texture asset name.
hash = HashName("assets\textures\environment\manmade\rh_hub_uniq_wood_pile_v01")
ScanFiles(hash)
I also tried various asset name combinations like prepending "pcx64-w\" or appending ".tr2pcd", ".pcd", ".dds", ...
Does anybody have an idea?
By the way, I use the hash algorithm from
http://svn.gib.me/public/crystaldynamics/trunk/ is it still valid?
This is pointless, I'll save you the trouble and explain why.
1. Each DRM section has it's own
unique hash name which is a unsigned 16-bit integer. Ekey's unpacker does not extract the sections with their hash names.
2. Each meshInfo[] contains a 32-bit integer which is an index into the material list (stored else where in the mesh file). The material list is just an array of 16-bit hash names which match the material hash section it uses.
3. At the end of the material files you should see a struct array sized 0x10. These are the texture definitions, each array starts with a 16-bit hash identical to the corresponding texture section it is referring to.
4. It is almost
impossible to implement auto-texturing. The materials specify all textures it utilises. Within the material file there is no flag which determines whether a texture definition is diffuse, normal, mask or specular textures. This is controlled directly by the shaders which are compiled so it's pretty much impossible.
I have confirmed this information for Tomb Raider Underworld by modifying the material file itself. Modifying the other data stored in the texture definition struct does nothing in regards to what texture is diffuse etc. Replacing the shader proved that my initial concerns are correct. This may have changed since Tomb Raider: Underworld but it's highly unlikely.
You can take a look at my Tomb Raider: Underworld Noesis script which does load material files and partially auto texture the meshes but it's not accurate all the time.
Regards.