Material importer / exporter (GMT <=> XML)

Discussion in 'Car Modding' started by K Szczech, Sep 15, 2012.

  1. K Szczech

    K Szczech Registered

    Joined:
    Oct 5, 2010
    Messages:
    1,720
    Likes Received:
    45
    First of all tool is unfinished, it's only an exporter right now, so GMT => XML only :)

    But exporting alone can be useful for car modders - here it is: LINK

    It's a small tool, much like the old command line material tool I've made for rFactor. You launch this tool in a directory with GMT files and it will load them all and create _export.xml file with all materials in it.

    It *should* support versions 2.51 and 2.52, although I only tested it on Clio (at first I only supported 2.52 and tested it on Monaco).
    It's not finished and not guaranteed to work, but may be helpful finding out how some animations and materials are configured in ISI cars.

    Things that are inconvenient in current version:
    1. some material flags and texture flags are simply named "FLAG_1", "FLAG_2" ... "FLAG_32"
    2. a few values are still exported as "UNKNOWN1", "UNKNOWN2", etc. since I don't know if these values are even used for anything
    3. XML format may not be the most human readable form, so perhaps I'll add double export - to .XML for editing and to .TXT for just viewing materials
    4. Animation types are exported as numbers (1 = no amination, 2 and above - different animation types)

    Here's an example output:

    Code:
      <MATERIAL>
        <NAME>CLIO_TIRE_SLICK</NAME>
        <FLAGS>FLAG_1;FLAG_2;FLAG_21;FLAG_24;specularM;emmissiveM;FLAG_31</FLAGS>
        <AMBIENT><R>1.00000</R><G>1.00000</G><B>1.00000</B><A>1.00000</A></AMBIENT>
        <DIFFUSE><R>1.00000</R><G>1.00000</G><B>1.00000</B><A>1.00000</A></DIFFUSE>
        <SPECULAR><R>0.61961</R><G>0.61961</G><B>0.61961</B><A>1.00000</A></SPECULAR>
        <EMMISIVE><R>0.00000</R><G>0.00000</G><B>0.00000</B><A>1.00000</A></EMMISIVE>
        <SRCBLEND>One</SRCBLEND>
        <DSTBLEND>Zero</DSTBLEND>
        <FSPECULAR>12.00000</FSPECULAR>
        <SHADER>L2SPECULARMAPT0</SHADER>
        <TEXTURE0>
          <NAME>clio_tire_slick.dds</NAME>
          <FLAGS>AutoMip;Trilinear</FLAGS>
          <UNKNOWN1>FFFFFFFF</UNKNOWN1>
          <ANIMATION>
            <TEXTURECOUNT>3</TEXTURECOUNT>
            <FRAMECOUNT>3</FRAMECOUNT>
            <FRAME0>0</FRAME0>
            <FRAME1>1</FRAME1>
            <FRAME2>2</FRAME2>
            <ANIMATIONTYPE>5</ANIMATIONTYPE>
            <FREQUENCY>1.000000</FREQUENCY>
          </ANIMATION>
          <ACTOR>1</ACTOR>
          <ACTION>3</ACTION>
          <APPLY>1</APPLY>
          <TEXSTAGE0>0</TEXSTAGE0>
          <TEXSTAGE1>0</TEXSTAGE1>
          <COLORKEY>0</COLORKEY>
          <UNKNOWN2>0</UNKNOWN2>
          <LODBIAS>0</LODBIAS>
          <UNKNOWN3>0</UNKNOWN3>
          <UNKNOWN4>0</UNKNOWN4>
          <FRESNELMIN>0</FRESNELMIN>
          <FRESNELMAX>0</FRESNELMAX>
          <FRESNELEXP>0</FRESNELEXP>
        </TEXTURE0>
        <TEXTURE1>
          <NAME>clio_tire_slick_s.dds</NAME>
          <FLAGS>AutoMip;Trilinear</FLAGS>
          <UNKNOWN1>FFFFFFFF</UNKNOWN1>
          <ANIMATION>
            <TEXTURECOUNT>3</TEXTURECOUNT>
            <FRAMECOUNT>3</FRAMECOUNT>
            <FRAME0>0</FRAME0>
            <FRAME1>1</FRAME1>
            <FRAME2>2</FRAME2>
            <ANIMATIONTYPE>5</ANIMATIONTYPE>
            <FREQUENCY>1.000000</FREQUENCY>
          </ANIMATION>
          <ACTOR>2</ACTOR>
          <ACTION>2</ACTION>
          <APPLY>1</APPLY>
          <TEXSTAGE0>1</TEXSTAGE0>
          <TEXSTAGE1>0</TEXSTAGE1>
          <COLORKEY>0</COLORKEY>
          <UNKNOWN2>0</UNKNOWN2>
          <LODBIAS>0</LODBIAS>
          <UNKNOWN3>0</UNKNOWN3>
          <UNKNOWN4>0</UNKNOWN4>
          <FRESNELMIN>0</FRESNELMIN>
          <FRESNELMAX>0</FRESNELMAX>
          <FRESNELEXP>0</FRESNELEXP>
        </TEXTURE1>
      </MATERIAL>
    This is one material definition, but of course this XML file will contain all materials found in GMT files.

    Feel free to post any flag / animation codes you find.

    As we gain some collective knowledge I will update this tool to use proper flag names.


    Some parameters are not relevant for us (for example - Actor, Action and Texstage only need to be set correctly by exporter so are of no concern to modders - only to tool makers).

    Cheers.
     
    Last edited by a moderator: Sep 21, 2012
  2. Traveller

    Traveller Member

    Joined:
    Oct 7, 2010
    Messages:
    864
    Likes Received:
    490
    Hmm. Perhaps we can work together. Here is my current work in progress.

    Code:
    ========================
    Material# 0
    Material Header:
    Material Info:
    Name:  CMWL02
    Flags: 0x68900003
    Ambient  Color: (R: (1.0,) G: (1.0,) B: (1.0,) A: (1.0,) )
    Diffuse  Color: (R: (1.0,) G: (1.0,) B: (1.0,) A: (1.0,) )
    Specular  Color: (R: (1.0,) G: (1.0,) B: (1.0,) A: (1.0,) )
    Emissive  Color: (R: (0.0,) G: (0.0,) B: (0.0,) A: (1.0,) )
    Source Blend: 2
    Destination Blend: 1
    Specular Power: 1.0
    Zero: 0.0
    Fresnel Value: 1.0
    Fresnel Minimum/ Maximum: 0.0 / 4.0
    ----------------------------
    DX9 Shader Information:
    Name: L2DIFFUSET0
    Effect: 
    Padding []
    ----------------------------
    Number of Textures: 1
    ----------------------------
    Texture 0 Information:
    Texture Name:  BUILD024.DDS
    Flags: 0x18
    MIP Level: -1
    Animation: 1
    Shader Actor: 1 - DIFFUSE
    Shader Action: 3 - MULTIPLY
    Cube Blend: 1.0
    Texture Stage: 0
    Anisotropic Filtering Level: 0
    Transparent Color  Color: (R: 0.0 G: 0.0 B: 0.0 A: 0.0 )
    Alpha Reference: (1,)
    Texture Bias: 0.0
    Shadow Bias: 1.0
    Padding: [(0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,), (0,)]
    
    ========================
    
     
  3. Johannes Rojola

    Johannes Rojola Registered

    Joined:
    Sep 8, 2011
    Messages:
    1,038
    Likes Received:
    38
    So much thank you, I can really make a lot out of this.
     
  4. K Szczech

    K Szczech Registered

    Joined:
    Oct 5, 2010
    Messages:
    1,720
    Likes Received:
    45
    New version available. You will find updated link in first post.

    ------------------------- Changes -------------------------

    1. Added the following material flags:
    - Blend - enabled whenever you set blendint to anything else than One / Zero
    - NoZBuff - *1
    - TwoSided
    - Sorted - *2
    - ambientD - if set, then "D" button is pressed near ambient color. Otherwise it's "M"
    - diffuseD - if set, then "D" button is pressed near diffuse color. Otherwise it's "M"
    - specularM - if set, then "M" button is pressed near specular color. Otherwise it's "D"
    - emmissiveM - if set, then "M" button is pressed near emissive color. Otherwise it's "D"

    *1 - this flag corresponds to "No Z Buff" in 3D Studio plugin, but doesn't seem to have any effect in DevMode
    *2 - when it's set, "Blend" flag doesn't get exported, but blending works nonetheless. Also, sorting works regardles if this flag is set or not, so in the end this flag seems to have no other use that allowing user to type offset in 3D Studio material plugin.

    Some flags seem permanently set in every material. Maybe I'll put them together and call "StandardFlags" or something, just to keep this export file cleaner.

    2. Added the following texture flags:
    - NoDetailReduct
    - RenderTgt
    - AutoMip
    - Trilinear
    - Aniso
    - Chroma
    - Unique
    - ClampU - set when "Tile" is cleared for U coordinate
    - ClampV - set when "Tile" is cleared for V coordinate
    - LiveMapper
    - NoCompress
    - Video
    - FrameWithoutZ - set when "Add Z Buf" is cleared for render targets
    - FrameBuffer

    Note that while "Video" flag is supported allready, GMT files wth video animation are not yet supported.

    3. Added names for blend modes

    Next update should include support for video animation and some more information being exported.
     
  5. Traveller

    Traveller Member

    Joined:
    Oct 7, 2010
    Messages:
    864
    Likes Received:
    490
    Please elaborate on this. For instance, the difference between "D" and "M".

    Code:
    - ambientD - if set, then "D" button is pressed near ambient color. Otherwise it's "M"
    - diffuseD - if set, then "D" button is pressed near diffuse color. Otherwise it's "M"
    - specularM - if set, then "M" button is pressed near specular color. Otherwise it's "D"
    - emmissiveM - if set, then "M" button is pressed near emissive color. Otherwise it's "D"
    
     
  6. Oleg

    Oleg Registered

    Joined:
    Sep 19, 2012
    Messages:
    20
    Likes Received:
    0
    And what is the actual difference between these modes?
     
  7. sugarfoot

    sugarfoot Registered

    Joined:
    Jan 3, 2012
    Messages:
    60
    Likes Received:
    3
    From the rF1 modding manual

    M and D buttons – these determine whether the specified color comes from a light source (D), or directly from the material (M)

    Tony
     
  8. K Szczech

    K Szczech Registered

    Joined:
    Oct 5, 2010
    Messages:
    1,720
    Likes Received:
    45
    No idea ;)
    I just added export of these flags state in my tool, that's all.

    Hmmm..... nope, still no idea :)

    I thought specified color comes from that color edit next to "D" and "M" buttons, because it's kinda... specified there? :) So how can we specify something and then point to where it comes from?

    We usually specify something and choose what it influences and how.
     
  9. Traveller

    Traveller Member

    Joined:
    Oct 7, 2010
    Messages:
    864
    Likes Received:
    490
    I'm just trying to make sure that I have the interactions and dependencies correct with what I'm working on. Apparently there is something more to flag set-- something about a color (presumably in 3DSMax). So that is something to look into further. Anyway, I have enough material-- no pun intended-- to keep me busy for while.
     
  10. Oleg

    Oleg Registered

    Joined:
    Sep 19, 2012
    Messages:
    20
    Likes Received:
    0
    I think the difference will come up in night-light when colored light is shining around models. That's where these options will probably play effect.
     
  11. blakboks

    blakboks Registered

    Joined:
    Oct 20, 2010
    Messages:
    843
    Likes Received:
    30
    Can anyone explain what exactly 'Add Z Buf' means and how it's used? When would you want / not want to check it?
     
  12. Johannes Rojola

    Johannes Rojola Registered

    Joined:
    Sep 8, 2011
    Messages:
    1,038
    Likes Received:
    38
    At least it is used with car gauges to tell the needle texture to find the gauge texture. I don't know if there is other usages...
     
  13. lordpantsington

    lordpantsington Registered

    Joined:
    Oct 5, 2010
    Messages:
    849
    Likes Received:
    79
    Don't D and M stand for Divide and Multiply?
     
  14. Oleg

    Oleg Registered

    Joined:
    Sep 19, 2012
    Messages:
    20
    Likes Received:
    0
    I think this option enables (on) and disables (off) z-write operation of rendered pixels. This should be toggled On to all materials except alpha-blended overlay effects. For example, this should be off for smoke generator or lens flare effects to prevent their z-fight artifacts.
     
  15. Oleg

    Oleg Registered

    Joined:
    Sep 19, 2012
    Messages:
    20
    Likes Received:
    0
    These could also be "take color from": Directly (from each vertex) and Material.
     
  16. Traveller

    Traveller Member

    Joined:
    Oct 7, 2010
    Messages:
    864
    Likes Received:
    490
    Does anyone have the bit positions of the flags? Here's what I have for rF1/rF2. Additions and/or corrections are appreciated. PM me if you like.

    Code:
    GMTHeader:
            #0x80000000 = ?
            #0x40000000 = ?
            #0x20000000 = ?
            #0x10000000 = ?
            #0x08000000 = ?
            #0x04000000 = Lit At Night
            #0x02000000 = ?
            #0x01000000 = ?
            #0x00800000 = ?
            #0x00400000 = ?
            #0x00200000 = ?
            #0x00100000 = ?
            #0x00080000 = ?
            #0x00040000 = ?
            #0x00020000 = ?
            #0x00010000 = ?
            #0x00008000 = ?
            #0x00004000 = ?
            #0x00002000 = ?
            #0x00001000 = ?
            #0x00000800 = ?
            #0x00000400 = ?
            #0x00000200 = ?
            #0x00000100 = ?
            #0x00000080 = ?
            #0x00000040 = ?
            #0x00000020 = ? (Default = Set) rF1 only?
            #0x00000010 = ?
            #0x00000008 = ? (rF2 ?)
            #0x00000004 = ?
            #0x00000002 = ?
            #0x00000001 = ?
    
    Mesh:
            #0x80000000 = ?
            #0x40000000 = ?
            #0x20000000 = ? {Default = Set}
            #0x10000000 = ?
            #0x08000000 = ?
            #0x04000000 = ?
            #0x02000000 = ?
            #0x01000000 = ?
            #0x00800000 = ?
            #0x00400000 = ?
            #0x00200000 = ?
            #0x00100000 = ?
            #0x00080000 = ?
            #0x00040000 = ?
            #0x00020000 = ?
            #0x00010000 = ?
            #0x00008000 = ?
            #0x00004000 = ? {Default = Set}
            #0x00002000 = ?
            #0x00001000 = ?
            #0x00000800 = ?
            #0x00000400 = ?
            #0x00000200 = ?
            #0x00000100 = ?
            #0x00000080 = ?
            #0x00000040 = ?
            #0x00000020 = ? Specular Map UV Exists?
            #0x00000010 = ? {Default = Set}
            #0x00000008 = ?
            #0x00000004 = ? Normal Map UV Exists?
            #0x00000002 = ?
            #0x00000001 = ? {Default = Set}
    
    Material:
            #0x80000000 = ?
            #0x40000000 = ?  {Default, Set}
            #0x20000000 = EmissiveM : True = float values, false = integer values
            #0x10000000 = ?
            #0x08000000 = ?  {Default, Set}
            #0x04000000 = SpecularM : True = float values, false = integer values
            #0x02000000 = ?
            #0x01000000 = DiffuseM : True = float values, false = integer values
            #0x00800000 = ?  {Default, Set}
            #0x00400000 = ?
            #0x00200000 = AmbientM : True = float values, false = integer values
            #0x00100000 = ?  {Default, Set}
            #0x00080000 = ?
            #0x00040000 = ?
            #0x00020000 = ?
            #0x00010000 = Glass Material
            #0x00008000 = ?
            #0x00004000 = ?
            #0x00002000 = ?
            #0x00001000 = ?
            #0x00000800 = Double Sided Material
            #0x00000400 = ?
            #0x00000200 = ?
            #0x00000100 = No Clipping
            #0x00000080 = ?
            #0x00000040 = Specular
            #0x00000020 = Blend
            #0x00000010 = ?
            #0x00000008 = ?
            #0x00000004 = ?
            #0x00000002 = ? Auto
            #0x00000001 = ? Auto
    
    Texture
            #0x80000000 = ?
            #0x40000000 = ?
            #0x20000000 = ?
            #0x10000000 = ?
            #0x08000000 = ?
            #0x04000000 = Video
            #0x02000000 = ?
            #0x01000000 = ?
            #0x00800000 = ?
            #0x00400000 = ?
            #0x00200000 = ?
            #0x00100000 = ?
            #0x00080000 = No Texture Compression
            #0x00040000 = ?
            #0x00020000 = Mirror V
            #0x00010000 = Mirror U
            #0x00008000 = ?
            #0x00004000 = ?
            #0x00002000 = ?
            #0x00001000 = ?
            #0x00000800 = Clamp V
            #0x00000400 = Clamp U
            #0x00000200 = ?
            #0x00000100 = Unique
            #0x00000080 = Use Color Key; Otherwise Use Alpha Channel
            #0x00000040 = ?
            #0x00000020 = ?
            #0x00000010 = ?
            #0x00000008 = MipMap
            #0x00000004 = ?
            #0x00000002 = Render
            #0x00000001 = No Reduce
    
     
    Last edited by a moderator: Jan 7, 2013
  17. Fabio Pittol

    Fabio Pittol Registered

    Joined:
    Oct 4, 2010
    Messages:
    274
    Likes Received:
    71
    Guys, I was checking out the exported and came across an odd issue (ok, not really an issu

    Checking out some ISI cars, the WCCARBODY has the TEXTURE0 (and some others) with this tag:

    <FLAGS>AutoMip;Trilinear</FLAGS>

    But everytime I try to export, mine looks like this:

    <FLAGS>AutoMip;Trilinear;FrameWithoutZ</FLAGS>

    The FrameWithoutZ only goes away if I check Render Tgt, and Add Z Buffer. But when I do that, the RenderTgt also appears on the flags, so it's probably not the case.

    Am I doing something wrong? Or maybe it's because some update from ISI since the exporter release?

    Thanks in advance.
     

Share This Page