1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Decoding the Saints Row 3 mesh format.

Discussion in 'Guides and Tutorials' started by scanti, Jun 16, 2012.

  1. flow754

    flow754 Modding patch tester

    Is the script available to download somewhere? I'd be interested in porting it to Blender/Python.
  2. Sure, but they are still in development so things are going to change over time;
    SRIII formatdescription and maxscripts

    There is already quite some blender stuff available I think;

    Ps, here's a new screenshot of the progress on shaundi. Corrected normalmaps and a nice high-res head model. Doesn't she look good?

    Next step is proper material parsing. I deleted the old stuff and need to re-write it properly. And I need to figure out how the materials are being constructed.
    Last edited: Mar 6, 2017

  3. Give this man two bottles of rum, gentlemen!
    Awesome work.
    Admixon likes this.
  4. Fixed a small issue in the importer, so now we have Oleg!
    Download new version here:

    I still haven't figured out where the proper scales are referenced. They should be in the files somewhere. It seems very unlikely that they are hardcoded.
    Also still have to write a proper material parser. These textures were all manually applied. The old material stuff I had was shit.

    tyhender, Quantum and flow754 like this.
  5. Here's what I figured out about the material format in SR4 so far by playing with the material cruncher:

    matlib_pc format:

    Code (Text):

    char[4] signature
    uint64 strings_size
    uint64 strings_count
    align 16
    char[strings_size] strings1 // zero terminated strings
    align 16
    uint8[56] unknown1
    uint64 materials_count
    uint8[32] unknown2
    char[strings_count][] strings2 // No size, just keep reading strings until you have strings_count of them
    Material for ir_at_bbsimple1. ir_at_bbsimple3 is similar, except it does not have unknown6 to unknown12.

    Code (Text):

    uint64 size // size of the material entry
    uint8[8] unknown1
    uint32 flags
    uint8[4] unknown2
    uint8[36] unknown3
    uint8[4] unknown4
    uint8[4] unknown5
    uint32 unknown6
    uint8[4] unknown7
    uint32 unknown8
    uint32 unknown9
    uint8[4] unknown10
    uint32 unknown11
    uint8[28] unknown12
    uint8[12] unknown13
    fxparam[] params
    uint8[32] unknown32
    fxparam is always 16 bytes and can be a single float or vector of 4. The amount and type is defined in each shaders .fxinfo_pc file. They are inside the shaders.vpp_pc file for the SRIV SDK.


    Code (Text):

    Mat_Alpha_Mode 0x2
    Mat_Glows 0x4
    Mat_Distortion 0x8
    Mat_Cull_Mode 0x10
    Mat_Shadow_Cull_Mode 0x200
    norender 0x1000
    I used uint8 as the generic bytes type. The difference between uint8[4] and uint32 is that uint8[4] usually has values higher than 1 million, which is very uncommon for actual integers, I suspect they're hashes. Everything I wrote is mostly guessing, don't be confused if it doesn't match up with your files.

    Here's a gist with my Python (3) code: https://gist.github.com/Yepoleb/ce56be1f52322ae69887c2ed0736983f
    Quantum and harmalarm[NL] like this.
  6. Thanks man! To be honest I've been spending some time investigating the rig_pc files for characters and have now got a proper rig parser. Next Item on the agenda is to figure out the vertex weights to rig the character to the bones. I think I already found out how to do that.
    After this I will work on the materials and have a proper look at your findings ;)
    tyhender and Quantum like this.