Home Risen Risen2 Risen3 Forum English Russian

Registrieren Hilfe Kalender Heutige Beiträge
Seite 1 von 2 12 Letzte »
Ergebnis 1 bis 20 von 21
  1. #1 Zitieren
    research Avatar von NicoDE
    Registriert seit
    Dec 2004
    Beiträge
    7.409
    I started to explore the compiled Shader Material files.
    Here is a description/listing of the /data/common/materials/(null)._xmat:
    Code:
    ResourceHeader {
        GEU32       Revision;               // 0x31305247 ("GR01")
        GEU32       DataRevision;           // 0x31304D53 ("SM01")
        GEU32       PropertyObjectOffset;   // 0x00000028
        GEU32       PropertyObjectSize;     // 0x000000D2
        GEU32       ResourceDataOffset;     // 0x000000FA
        GEU32       ResourceDataSize;       // 0x00000579
        SFFFileTime RawModificationTime;    // 0x01C8328915EFBB00 (2007-11-29T13:09:34Z)
        GEChar      RawFileExtension[ 8 ];  // ".xshmat\0"
    }
    PropertyObject {
        GEU16  AccessorVersion;    // 0x0001
        GEBool HasPropertyObject;  // 0x01
        if( HasPropertyObject ) {
            GEU16    Unknown1;      // 0x0001
            GEBool   Unknown2;      // 0x01
            bCString ClassName;     // 0x0013, "eCMaterialResource2"
            GEU16    Unknown3;      // 0x0001
            GEBool   Unknown4;      // 0x00
            GEU16    ClassVersion;  // 0x00C9
            GEU16    Unknown5;      // 0x00C9
            GEU32    DataSize;      // 0x000000AC
            Data {
                PropertyData {
                    GEU16 Version;        // 0x00C9
                    GEU32 PropertyCount;  // 0x00000004
                    Property[ 0 ] {
                        bCString Name;      // 0x000E, "PhysicMaterial"
                        bCString Type;      // 0x0029, "bTPropertyContainer<enum eEShapeMaterial>"
                        GEU16    Version;   // 0x001E
                        GEU32    DataSize;  // 0x00000006
                        Data {
                            GEU16 Version;  // 0x00C9
                            GEU32 Value;    // 0x00000000 (eEShapeMaterial_None)
                        }
                    }
                    Property[ 1 ] {
                        bCString Name;      // 0x0011, "IgnoredByTraceRay"
                        bCString Type;      // 0x0004, "bool"
                        GEU16    Version;   // 0x001E
                        GEU32    DataSize;  // 0x00000001
                        Data {
                            GEBool Value;  // 0x00 (False)
                        }
                    }
                    Property[ 2 ] {
                        bCString Name;      // 0x0010, "DisableCollision"
                        bCString Type;      // 0x0004, "bool"
                        GEU16    Version;   // 0x001E
                        GEU32    DataSize;  // 0x00000001
                        Data {
                            GEBool Value;  // 0x00 (False)
                        }
                    }
                    Property[ 3 ] {
                        bCString Name;      // 0x000F, "DisableResponse"
                        bCString Type;      // 0x0004, "bool"
                        GEU16    Version;   // 0x001E
                        GEU32    DataSize;  // 0x00000001
                        Data {
                            GEBool Value;  // 0x00 (False)
                        }
                    }
                }
                ClassData {
                    GEU16 Version;  // 0x00C9
                }
            }
        }
    }
    ResourceData {
        GEU16  AccessorVersion;    // 0x0001
        GEBool HasPropertyObject;  // 0x01
        if( HasPropertyObject ) {
            GEU16    Unknown1;      // 0x0001
            GEBool   Unknown2;      // 0x01
            bCString ClassName;     // 0x000F, "eCShaderDefault"
            GEU16    Unknown3;      // 0x0001
            GEBool   Unknown4;      // 0x00
            GEU16    ClassVersion;  // 0x0003
            GEU16    Unknown5;      // 0x00C9
            GEU32    DataSize;      // 0x00000557
            Data {
                PropertyData {
                    GEU16 Version;        // 0x00C9
                    GEU32 PropertyCount;  // 0x0000000A
                    Property[ 0 ] {
                        bCString Name;      // 0x0012, "TransformationType"
                        bCString Type;      // 0x0038, "bTPropertyContainer<enum eEShaderMaterialTransformation>"
                        GEU16    Version;   // 0x001E
                        GEU32    DataSize;  // 0x00000006
                        Data {
                            GEU16 Version;  // 0x00C9
                            GEU32 Value;    // 0x00000003 (eEShaderMaterialTransformation_Tree_Branches)
                        }
                    }
                    Property[ 1 ] {
                        bCString Name;      // 0x000E, "EnableSpecular"
                        bCString Type;      // 0x0004, "bool"
                        GEU16    Version;   // 0x001E
                        GEU32    DataSize;  // 0x00000001
                        Data {
                            GEBool Value;  // 0x01 (True)
                        }
                    }
                    Property[ 2 ] {
                        bCString Name;      // 0x000F, "DisableLighting"
                        bCString Type;      // 0x0004, "bool"
                        GEU16    Version;   // 0x001E
                        GEU32    DataSize;  // 0x00000001
                        Data {
                            GEBool Value;  // 0x00 (False)
                        }
                    }
                    Property[ 3 ] {
                        bCString Name;      // 0x0009, "BlendMode"
                        bCString Type;      // 0x0033, "bTPropertyContainer<enum eEShaderMaterialBlendMode>"
                        GEU16    Version;   // 0x001E
                        GEU32    DataSize;  // 0x00000006
                        Data {
                            GEU16 Version;  // 0x00C9
                            GEU32 Value;    // 0x00000001 (eEShaderMaterialBlendMode_Masked)
                        }
                    }
                    Property[ 4 ] {
                        bCString Name;      // 0x000D, "MaskReference"
                        bCString Type;      // 0x0004, "char"
                        GEU16    Version;   // 0x001E
                        GEU32    DataSize;  // 0x00000001
                        Data {
                            GEU8 Value;  // 0x00
                        }
                    }
                    Property[ 5 ] {
                        bCString Name;      // 0x0010, "MaxShaderVersion"
                        bCString Type;      // 0x0031, "bTPropertyContainer<enum eEShaderMaterialVersion>"
                        GEU16    Version;   // 0x001E
                        GEU32    DataSize;  // 0x00000006
                        Data {
                            GEU16 Version;  // 0x00C9
                            GEU32 Value;    // 0x00000003 (eEShaderMaterialVersion_3_0)
                        }
                    }
                    Property[ 6 ] {
                        bCString Name;      // 0x0010, "FallbackMaterial"
                        bCString Type;      // 0x001F, "bCImageOrMaterialResourceString"
                        GEU16    Version;   // 0x001E
                        GEU32    DataSize;  // 0x00000002
                        Data {
                            bCString Value;  // 0x0000 ("")
                        }
                    }
                    Property[ 7 ] {
                        bCString Name;      // 0x000C, "UseDepthBias"
                        bCString Type;      // 0x0004, "bool"
                        GEU16    Version;   // 0x001E
                        GEU32    DataSize;  // 0x00000001
                        Data {
                            GEBool Value;  // 0x00 (False)
                        }
                    }
                    Property[ 8 ] {
                        bCString Name;      // 0x0011, "TradeAlphaAsSolid"
                        bCString Type;      // 0x0004, "bool"
                        GEU16    Version;   // 0x001E
                        GEU32    DataSize;  // 0x00000001
                        Data {
                            GEBool Value;  // 0x00 (False)
                        }
                    }
                    Property[ 9 ] {
                        bCString Name;      // 0x000E, "RenderPriority"
                        bCString Type;      // 0x0003, "int"
                        GEU16    Version;   // 0x001E
                        GEU32    DataSize;  // 0x00000004
                        Data {
                            GEInt Value;  // 0x00000000
                        }
                    }
                }
                ClassData {
                    GEU16 Version;  // 0x0003
                    ColorSrcDiffuse {
                        GEU32 Version;  // 0x0000029A
                        if( Version >= 666 ) {
                            GEU32 ColorComponent;  // 0x00000000 (eEShaderColorSrcComponent_None)
                            GEU32 ColorModifier;   // 0x00000000 (eEShaderColorModifier_None)
                        }
                        bCGuid Token;  // {80926BF2-8465-4C9D-9FAF-87AAB09AB553}, 0x01, __, __, __
                    }
                    ColorSrcOpacity {
                        GEU32 Version;  // 0x0000029A
                        if( Version >= 666 ) {
                            GEU32 ColorComponent;  // 0x00000000 (eEShaderColorSrcComponent_None)
                            GEU32 ColorModifier;   // 0x00000000 (eEShaderColorModifier_None)
                        }
                        bCGuid Token;  // {________-____-____-____-____________}, 0x00, __, __, __
                    }
                    ColorSrcSelfIllumination {
                        GEU32 Version;  // 0x0000029A
                        if( Version >= 666 ) {
                            GEU32 ColorComponent;  // 0x00000000 (eEShaderColorSrcComponent_None)
                            GEU32 ColorModifier;   // 0x00000000 (eEShaderColorModifier_None)
                        }
                        bCGuid Token;  // {________-____-____-____-____________}, 0x00, __, __, __
                    }
                    ColorSrcSpecular {
                        GEU32 Version;  // 0x0000029A
                        if( Version >= 666 ) {
                            GEU32 ColorComponent;  // 0x00000000 (eEShaderColorSrcComponent_None)
                            GEU32 ColorModifier;   // 0x00000000 (eEShaderColorModifier_None)
                        }
                        bCGuid Token;  // {49F73761-EC0C-4CD1-82D5-EF4FD671798F}, 0x01, __, __, __
                    }
                    ColorSrcSpecularPower {
                        GEU32 Version;  // 0x0000029A
                        if( Version >= 666 ) {
                            GEU32 ColorComponent;  // 0x00000005 (eEShaderColorSrcComponent_Alpha)
                            GEU32 ColorModifier;   // 0x00000000 (eEShaderColorModifier_None)
                        }
                        bCGuid Token;  // {49F73761-EC0C-4CD1-82D5-EF4FD671798F}, 0x01, __, __, __
                    }
                    ColorSrcNormal {
                        GEU32 Version;  // 0x0000029A
                        if( Version >= 666 ) {
                            GEU32 ColorComponent;  // 0x00000000 (eEShaderColorSrcComponent_None)
                            GEU32 ColorModifier;   // 0x00000000 (eEShaderColorModifier_None)
                        }
                        bCGuid Token;  // {________-____-____-____-____________}, 0x00, __, __, __
                    }
                    if( Version >= 2 ) {
                        ColorSrcDistortion {
                            GEU32 Version;  // 0x0000029A
                            if( Version >= 666 ) {
                                GEU32 ColorComponent;  // 0x00000000 (eEShaderColorSrcComponent_None)
                                GEU32 ColorModifier;   // 0x00000000 (eEShaderColorModifier_None)
                            }
                            bCGuid Token;  // {________-____-____-____-____________}, 0x00, __, __, __
                        }
                    }
                    if( Version >= 3 ) {
                        ColorSrcLightEmission {
                            GEU32 Version;  // 0x0000029A
                            if( Version >= 666 ) {
                                GEU32 ColorComponent;  // 0x00000000 (eEShaderColorSrcComponent_None)
                                GEU32 ColorModifier;   // 0x00000000 (eEShaderColorModifier_None)
                            }
                            bCGuid Token;  // {________-____-____-____-____________}, 0x00, __, __, __
                        }
                    }
                    eCShaderBase {
                        GEU16 Version;  // 0x0001
                        eCShaderEllementBase {
                            GEU16  Version;       // 0x0002
                            bCGuid Token;         // {5578023A-6597-42BE-BE8C-6BD44ADB6F9E}, 0x01, __, __, __
                            bCRect EditorLayout;  // 0x00000020, 0x00000094, 0x00000110, 0x0000013C
                            if( Version >= 2 ) {
                                GEBool Unknown;  // 0x00 (False)
                            }
                        }
                        GEU32 ShaderEllementCount;  // 0x00000002
                        ShaderEllement[ 0 ] {
                            GEU16  AccessorVersion;    // 0x0001
                            GEBool HasPropertyObject;  // 0x01
                            if( HasPropertyObject ) {
                                GEU16    Unknown1;      // 0x0001
                                GEBool   Unknown2;      // 0x01
                                bCString ClassName;     // 0x0011, "eCColorSrcSampler"
                                GEU16    Unknown3;      // 0x0001
                                GEBool   Unknown4;      // 0x00
                                GEU16    ClassVersion;  // 0x0001
                                GEU16    Unknown5;      // 0x00C9
                                GEU32    DataSize;      // 0x00000182
                                Data {
                                    PropertyData {
                                        GEU16 Version;        // 0x00C9
                                        GEU32 PropertyCount;  // 0x00000005
                                        Property[ 0 ] {
                                            bCString Name;      // 0x000D, "ImageFilePath"
                                            bCString Type;      // 0x0015, "bCImageResourceString"
                                            GEU16    Version;   // 0x001E
                                            GEU32    DataSize;  // 0x00000002
                                            Data {
                                                bCString Value;  // 0x0000 ("")
                                            }
                                        }
                                        Property[ 1 ] {
                                            bCString Name;      // 0x000A, "TexRepeatU"
                                            bCString Type;      // 0x0033, "bTPropertyContainer<enum eEColorSrcSampleTexRepeat>"
                                            GEU16    Version;   // 0x001E
                                            GEU32    DataSize;  // 0x00000006
                                            Data {
                                                GEU16 Version;  // 0x00C9
                                                GEU32 Value;    // 0x00000000 (eEColorSrcSampleTexRepeat_Wrap)
                                            }
                                        }
                                        Property[ 2 ] {
                                            bCString Name;      // 0x000A, "TexRepeatV"
                                            bCString Type;      // 0x0033, "bTPropertyContainer<enum eEColorSrcSampleTexRepeat>"
                                            GEU16    Version;   // 0x001E
                                            GEU32    DataSize;  // 0x00000006
                                            Data {
                                                GEU16 Version;  // 0x00C9
                                                GEU32 Value;    // 0x00000000 (eEColorSrcSampleTexRepeat_Wrap)
                                            }
                                        }
                                        Property[ 3 ] {
                                            bCString Name;      // 0x000E, "AnimationSpeed"
                                            bCString Type;      // 0x0005, "float"
                                            GEU16    Version;   // 0x001E
                                            GEU32    DataSize;  // 0x00000004
                                            Data {
                                                GEFloat Value;  // 0x00000000 (0.0)
                                            }
                                        }
                                        Property[ 4 ] {
                                            bCString Name;      // 0x000C, "SwitchRepeat"
                                            bCString Type;      // 0x0030, "bTPropertyContainer<enum eEColorSrcSwitchRepeat>"
                                            GEU16    Version;   // 0x001E
                                            GEU32    DataSize;  // 0x00000006
                                            Data {
                                                GEU16 Version;  // 0x00C9
                                                GEU32 Value;    // 0x00000000 (eEColorSrcSwitchRepeat_Repeat)
                                            }
                                        }
                                    }
                                    ClassData {
                                        GEU16 Version;  // 0x0001
                                        TexCoord {
                                            eCTexCoordSrcProxy {
                                                GEInt  VertexTexCoord;  // 0x00000000
                                                bCGuid Token;           // {________-____-____-____-____________}, 0x00, __, __, __
                                            }
                                        }
                                        GEU32 Unknown;  // 0xFFFFFFFF
                                        eCColorSrcBase {
                                            GEU16 Version;  // 0x0001
                                            eCShaderEllementBase {
                                                GEU16  Version;       // 0x0002
                                                bCGuid Token;         // {80926BF2-8465-4C9D-9FAF-87AAB09AB553}, 0x01, __, __, __
                                                bCRect EditorLayout;  // 0x000001B0, 0x00000020, 0x000002A0, 0x000000C8
                                                if( Version >= 2 ) {
                                                    GEBool Unknown;  // 0x00 (False)
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        ShaderEllement[ 1 ] {
                            GEU16  AccessorVersion;    // 0x0001
                            GEBool HasPropertyObject;  // 0x01
                            if( HasPropertyObject ) {
                                GEU16    Unknown1;      // 0x0001
                                GEBool   Unknown2;      // 0x01
                                bCString ClassName;     // 0x0012, "eCColorSrcConstant"
                                GEU16    Unknown3;      // 0x0001
                                GEBool   Unknown4;      // 0x00
                                GEU16    ClassVersion;  // 0x0001
                                GEU16    Unknown5;      // 0x00C9
                                GEU32    DataSize;      // 0x00000074
                                Data {
                                    PropertyData {
                                        GEU16 Version;        // 0x00C9
                                        GEU32 PropertyCount;  // 0x00000002
                                        Property[ 0 ] {
                                            bCString Name;      // 0x0005, "Color"
                                            bCString Type;      // 0x000C, "bCFloatColor"
                                            GEU16    Version;   // 0x001E
                                            GEU32    DataSize;  // 0x00000010
                                            Data {
                                                bCFloatColor Value;  // 0x100F1960 (__vftbl?!), 0.0,  0.0, 0.0
                                            }
                                        }
                                        Property[ 1 ] {
                                            bCString Name;      // 0x0005, "Alpha"
                                            bCString Type;      // 0x0005, "float"
                                            GEU16    Version;   // 0x001E
                                            GEU32    DataSize;  // 0x00000004
                                            Data {
                                                GEFloat Value;  // 0x00000000 (0.0)
                                            }
                                        }
                                    }
                                    ClassData {
                                        GEU16 Version;  // 0x0001
                                        eCColorSrcBase {
                                            GEU16 Version;  // 0x0001
                                            eCShaderEllementBase {
                                                GEU16  Version;       // 0x0002
                                                bCGuid Token;         // {49F73761-EC0C-4CD1-82D5-EF4FD671798F}, 0x01, __, __, __
                                                bCRect EditorLayout;  // 0x000001B0, 0x000000E8, 0x000002A0, 0x00000190
                                                if( Version >= 2 ) {
                                                    GEBool Unknown;  // 0x00 (False)
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    The resource data is an eCShaderBase-based property object.
    The spec is not sufficient to read all *._xmat (other classes wil be documented later) - but you can already get an idea what is included in a Shader Material and how proxies are resolved by Tokens to ShaderEllements.
    Angehängte Dateien
    "Unter diesen schwierigen Umständen bin ich mir sicher, daß diese guten Menschen meinen augenblicklichen Bedarf an deren Gold verstehen werden." -- Connor
    NicoDE ist offline Geändert von NicoDE (04.12.2010 um 03:40 Uhr)

  2. #2 Zitieren
    Ehrengarde Avatar von Baltram
    Registriert seit
    Jun 2006
    Beiträge
    2.264


    It so happens that I had just started working on a xmat editor (only to clone & modify existing mats) - so it's really convenient to have all this info about 'ClassData' now, I didn't quite understand this before. Thank you!
    Baltram ist offline

  3. #3 Zitieren
    research Avatar von NicoDE
    Registriert seit
    Dec 2004
    Beiträge
    7.409
    First let’s recap how property objects (derived from bCObjectBase) are streamed with/without an accessor:
    Code:
    bCAccessorPropertyObject {
        GEU16  Version;  // 0x0001
        GEBool HasPropertyObject;
        if( GETrue == HasPropertyObject ) {
            GEU16    Reserved1;  // 0x0001
            GEBool   Reserved2;  // 0x01 (GETrue)
            bCString ClassName;
            GEU16    Reserved3;  // 0x0001
            GEBool   Reserved4;  // 0x00 (GEFalse)
            GEU16    ClassVersion;
            bCObjectBase {
                GEU16 Version;  // 0x00C9 (201)
                GEU32 Size;
                Data {
                    PropertyData {
                        GEU16 Version;  // 0x00C9 (201)
                        GEU32 Count;
                        for( Count ) {
                            bCString Name;
                            bCString Type;
                            GEU16    Version;  // 0x001E (30)
                            GEU32    Size;
                            Data {
                                GEU8 Value[ Size ];
                            }
                        }
                    }
                    ClassData {
                        // ClassName::OnRead/OnWrite()
                        // GEU16 ClassVersion; ...
                    }
                }
            }
        }
    }
    All properties and the class data block can be skipped.
    But
    • to parse the property data your have to support all used classes (objects can also be properties),
    • and to parse the class data blocks you have to know how each used <ClassName>::OnRead/OnWrite is implemented (including the version handling).


    Compiled Shader Material resources are nothing else than bCAccessorPropertyObject<eCMaterialResource2> (Object) as header and bCAccessorPropertyObject<eCShaderBase> (Object.GetShader) as data.

    ps: 201 is the current property system persistence version - therefore you will see it very often.

    pps: For some classes (eCGfxObject, eCNode, eCVegetation_Grid, eCVegetation_GridNode, gCWaterSubZone_PS) the PropertyObjectType seems to include a Flag (0x00000001) that results in skipping/ignoring the properties while reading/writing it. In this case the bCObjectBase block only contains the ClassData (ClassName::OnRead/OnWrite).
    "Unter diesen schwierigen Umständen bin ich mir sicher, daß diese guten Menschen meinen augenblicklichen Bedarf an deren Gold verstehen werden." -- Connor
    NicoDE ist offline Geändert von NicoDE (07.01.2011 um 13:42 Uhr)

  4. #4 Zitieren
    Ehrengarde Avatar von Baltram
    Registriert seit
    Jun 2006
    Beiträge
    2.264
    Zitat Zitat von NicoDE Beitrag anzeigen
    • to parse the property data your have to support all used classes (objects can also be properties),
    • and to parse the class data blocks you have to know how each used <ClassName>::OnRead/OnWrite is implemented (including the version handling).
    That would be the clean way.

    But to access the most important data like texture paths and have, that way, at least a provisoric control over the materials, wouldn't it suffice to provide
    • only the commonly used property classes (rest can be skipped or treated as GEU8[size])
    • dummy functions for each type of ClassData found in the ~500 material files (or even skip ClassData)
    ?

    For example TPLEdit is a bit like that, I guess.

    Wondering what's the reason for them to choose 666, besides.
    Baltram ist offline

  5. #5 Zitieren
    research Avatar von NicoDE
    Registriert seit
    Dec 2004
    Beiträge
    7.409
    Some notes about "random" values...

    Code:
    bCGuid {
        GUID   Guid;
        GEBool Valid;
        GEU8   Alignment[ 3 ];
    }
    bCGuid is streamed as block of 0x14 (20) bytes - this includes the alignment that compiler generated for this class. The Alignment bytes are almost always filled with garbage.
    The value of Guid should be ignored if Valid is GEFalse (0x00).

    bCFloatColor streaming seems to be implemented as Read/Write(this, sizeof(*this)). But bCFloatColor has virtual functions. Therefore the implicitly generated member __vftbl is also streamed. This is very dangerous - after reading a bCFloatColor the virtual function table pointer might/will point to the wrong memory location (the virtual functions cannot be safely called anymore).
    Therefore you should set the first pointer to 0 if you generate/modify bCFloatColor.

    Zitat Zitat von Baltram Beitrag anzeigen
    Wondering what's the reason for them to choose 666, besides.
    The first version of eCColorSrcProxy had only ColorComponent and Token. Later they introduced a Version (the first version value must be greater than the highest value of eEShaderColorSrcComponent that might happen in the future).
    "Unter diesen schwierigen Umständen bin ich mir sicher, daß diese guten Menschen meinen augenblicklichen Bedarf an deren Gold verstehen werden." -- Connor
    NicoDE ist offline Geändert von NicoDE (04.12.2010 um 00:45 Uhr)

  6. #6 Zitieren
    research Avatar von NicoDE
    Registriert seit
    Dec 2004
    Beiträge
    7.409
    Let’s talk about ClassData blocks

    Code:
    eCColorSrcProxy {
        eEShaderColorSrcComponent ColorComponent;
        if( ColorComponent >= 666 ) {
            eEShaderColorSrcComponent ColorComponent;
            eEShaderColorModifier     ColorModifier;
        }
        bCGuid Token;
    }
    
    enum eEShaderColorModifier
    {
        eEShaderColorModifier_Default  = 0x00000000,  // ""
        eEShaderColorModifier_Negate   = 0x00000001,  // "-"
        eEShaderColorModifier_Invert   = 0x00000002,  // "1-"
        eEShaderColorModifier_Saturate = 0x00000003,  // "saturate"
        eEShaderColorModifier_Ceil     = 0x00000004,  // "ceil"
        eEShaderColorModifier_Floor    = 0x00000005,  // "floor"
        eEShaderColorModifier_Abs      = 0x00000006,  // "abs"
        eEShaderColorModifier_Frac     = 0x00000007,  // "frac"
        eEShaderColorModifier_Count,
        eEShaderColorModifier_ForceDWORD = 0x7FFFFFFF
    };
    
    enum eEShaderColorSrcComponent
    {
        eEShaderColorSrcComponent_Default = 0x00000000,  // ""
        eEShaderColorSrcComponent_RGB     = 0x00000001,  // ".rgb"
        eEShaderColorSrcComponent_R       = 0x00000002,  // ".r"
        eEShaderColorSrcComponent_G       = 0x00000003,  // ".g"
        eEShaderColorSrcComponent_B       = 0x00000004,  // ".b"
        eEShaderColorSrcComponent_A       = 0x00000005,  // ".a"
        eEShaderColorSrcComponent_Count,
        eEShaderColorSrcComponent_ForceDWORD = 0x7FFFFFFF
    };
    eCColorSrcProxy.Token is used to resolve the ColorSrc property to a Shader Element.

    eCShaderBase is derived from eCShaderEllementBase and the class data includes an array of Shader Elements:
    Code:
    eCShaderEllementBase {
        GEU16  Version;  // 0x0002
        bCGuid Token;
        bCRect EditorLayout;
        if( Version >= 2 ) {
            GEBool Unknown;
        }
    }
    
    eCShaderBase {
        GEU16                Version;  // 0x0001
        eCShaderEllementBase Inherited;
        GEU32                ShaderElementCount;
        for( ShaderElementCount ) {
            bCAccessorPropertyObject< eCShaderEllementBase > ShaderElement;
        }
    }
    Here are the other Shader class data blocks:
    Code:
    eCShaderDefault {
        GEU16           Version;  // 0x0005
        eCColorSrcProxy ColorSrcDiffuse;
        eCColorSrcProxy ColorSrcOpacity;
        eCColorSrcProxy ColorSrcSelfIllumination;
        eCColorSrcProxy ColorSrcSpecular;
        eCColorSrcProxy ColorSrcSpecularPower;
        eCColorSrcProxy ColorSrcNormal;
        if( Version >= 2 ) {
            eCColorSrcProxy ColorSrcDistortion;
        }
        if( Version >= 3 ) {
            eCColorSrcProxy ColorSrcLightEmission;
        }
        eCShaderBase Inherited;
    }
    Code:
    eCShaderLeafs {
        eCShaderDefault Inherited;
    }
    Code:
    eCShaderLightStreaks {
        GEU16           Version;  // 0x0001
        eCColorSrcProxy ColorSrcDiffuse;
        eCShaderBase    Inherited;
    }
    Code:
    eCShaderParticle {
        GEU16           Version;  // 0x0001
        eCColorSrcProxy ColorSrcDiffuse;
        eCShaderBase    Inherited;
    }
    Code:
    eCShaderSkyDome {
        GEU16           Version;  // 0x0001
        eCColorSrcProxy ColorSrcClouds;
        eCColorSrcProxy ColorSrcAbsorbation;
        eCShaderBase    Inherited;
    }
    ps: The registered(possible/allowed) values for the bTPropertyContainer<enum Xxx> are listed here.
    "Unter diesen schwierigen Umständen bin ich mir sicher, daß diese guten Menschen meinen augenblicklichen Bedarf an deren Gold verstehen werden." -- Connor
    NicoDE ist offline Geändert von NicoDE (04.12.2010 um 03:39 Uhr)

  7. #7 Zitieren
    research Avatar von NicoDE
    Registriert seit
    Dec 2004
    Beiträge
    7.409
    The class data blocks of the Color Source elements:
    Code:
    eCColorSrcBase {
        GEU16                Version;  // 0x0001
        eCShaderEllementBase Inherited;
    }
    Code:
    eCColorSrcBlend {
        GEU16           Version;  // 0x0001
        eCColorSrcProxy ColorSrc1;
        eCColorSrcProxy ColorSrc2;
        eCColorSrcProxy BlendSrc;
        eCColorSrcBase  Inherited;
    }
    Code:
    eCColorSrcCamDistance {
        GEU16          Version;  // 0x0001
        eCColorSrcBase Inherited;
    }
    Code:
    eCColorSrcCamObstacle {
        GEU16          Version;  // 0x0001
        eCColorSrcBase Inherited;
    }
    Code:
    eCColorSrcCombiner {
        GEU16           Version;  // 0x0001
        eCColorSrcProxy ColorSrc1;
        eCColorSrcProxy ColorSrc2;
        eCColorSrcBase  Inherited;
    }
    Code:
    eCColorSrcConstant {
        GEU16          Version;  // 0x0001
        eCColorSrcBase Inherited;
    }
    Code:
    eCColorSrcConstantAnimation {
        GEU16          Version;  // 0x0001
        eCColorScale   ColorScale;
        eCColorSrcBase Inherited;
    }
    Code:
    eCColorSrcConstantSwitch {
        GEU16          Version;  // 0x0001
        eCColorSrcBase Inherited;
    }
    Code:
    eCColorSrcCubeSampler {
        GEU16          Version;  // 0x0001
        eCColorSrcBase Inherited;
    }
    Code:
    eCColorSrcFresnel {
        GEU16          Version;  // 0x0001
        eCColorSrcBase Inherited;
    }
    Code:
    eCColorSrcMask {
        GEU16           Version;  // 0x0001
        eCColorSrcProxy Color;
        eCColorSrcBase  Inherited;
    }
    Code:
    eCColorSrcSampler {
        GEU16              Version;  // 0x0001
        eCTexCoordSrcProxy TexCoord;
        GEU32              Unknown;  // 0xFFFFFFFF
        eCColorSrcBase     Inherited;
    }
    Code:
    eCColorSrcSkydomeSampler {
        GEU16          Version;  // 0x0001
        eCColorSrcBase Inherited;
    }
    Code:
    eCColorSrcVertexColor {
        GEU16          Version;  // 0x0001
        eCColorSrcBase Inherited;
    };
    And the referred member types:
    Code:
    eCColorScale {
        GEU32 Version;  // 0x00000001
        GEU32 ArraySize;
        if( ArraySize ) {
            GEU32 ItemCount;
            for( ItemCount ) {
                GEFloat Time;
                GEFloat Red;
                GEFloat Green;
                GEFloat Blue;
                GEFloat Alpha;
            }
        }
    }
    Code:
    eCTexCoordSrcProxy {
        GEInt  VertexTexCoord;
        bCGuid Token;
    }
    "Unter diesen schwierigen Umständen bin ich mir sicher, daß diese guten Menschen meinen augenblicklichen Bedarf an deren Gold verstehen werden." -- Connor
    NicoDE ist offline Geändert von NicoDE (04.12.2010 um 03:18 Uhr)

  8. #8 Zitieren
    research Avatar von NicoDE
    Registriert seit
    Dec 2004
    Beiträge
    7.409
    And finally the class data blocks of the Texture Coordinate Source elements:
    Code:
    eCTexCoordSrcBase {
        GEU16                Version;  // 0x0001
        eCShaderEllementBase Inherited;
    }
    Code:
    eCTexCoordSrcBumpOffset {
        GEU16              Version;  // 0x0001
        eCColorSrcProxy    Height;
        eCTexCoordSrcProxy TexCoord;
        eCTexCoordSrcBase  Inherited;
    }
    Code:
    eCTexCoordSrcColor {
        GEU16             Version;  // 0x0001
        eCColorSrcProxy   ColorU;
        eCColorSrcProxy   ColorV;
        eCTexCoordSrcBase Inherited;
    }
    Code:
    eCTexCoordSrcOscillator {
        GEU16              Version;  // 0x0001
        eCTexCoordSrcProxy TexCoord;
        eCTexCoordSrcBase  Inherited;
    }
    Code:
    eCTexCoordSrcReflect {
        eCTexCoordSrcBase Inherited;
    }
    Code:
    eCTexCoordSrcRotator {
        GEU16              Version;  // 0x0001
        eCTexCoordSrcProxy TexCoord;
        eCTexCoordSrcBase  Inherited;
    }
    Code:
    eCTexCoordSrcScale {
        GEU16              Version;  // 0x0001
        eCTexCoordSrcProxy TexCoord;
        eCTexCoordSrcBase  Inherited;
    }
    Code:
    eCTexCoordSrcScroller {
        GEU16              Version;  // 0x0001
        eCTexCoordSrcProxy TexCoord;
        eCTexCoordSrcBase  Inherited;
    };
    Good night to everyone.
    "Unter diesen schwierigen Umständen bin ich mir sicher, daß diese guten Menschen meinen augenblicklichen Bedarf an deren Gold verstehen werden." -- Connor
    NicoDE ist offline Geändert von NicoDE (04.12.2010 um 10:42 Uhr)

  9. #9 Zitieren
    research Avatar von NicoDE
    Registriert seit
    Dec 2004
    Beiträge
    7.409
    How to "upgrade" an eCShaderDefault to the current version:
    Code:
    if( Version < 4 ) {
        bCString TransformationTypeString;
        switch( TransformationType )
        {
        case eEShaderMaterialTransformation_Default:
            TransformationTypeString = "Default";
            break;
        case eEShaderMaterialTransformation_Skinned:
            TransformationTypeString = "Skinned";
            break;
        case eEShaderMaterialTransformation_Morphed:
            TransformationTypeString = "Morphed";
            break;
        case eEShaderMaterialTransformation_Skinned_Morphed:
            TransformationTypeString = "SkinnedMorphed";
            break;
        }
        if( !TransformationTypeString.IsEmpty() )
        {
            FrozenOverlayMaterial      = "Special_Overlay_Frozen_"      + TransformationTypeString + "._xmat";
            BurnedOverlayMaterial      = "Special_Overlay_Burned_"      + TransformationTypeString + "._xmat";
            HighlightedOverlayMaterial = "Special_Overlay_Highlighted_" + TransformationTypeString + "._xmat";
        }
    }
    Code:
    if( Version < 5 ) {
        switch( TransformationType ) {
        case eEShaderMaterialTransformation_Skinned:
        case eEShaderMaterialTransformation_Morphed:
        case eEShaderMaterialTransformation_Skinned_Morphed:
            BRDFLightingType = eEShaderMaterialBRDFType_WrapAround;
            break;
        }
    }
    ps: "Special_Overlay_*_Morphed._xmat" do not exists - however, this is what the Engine does when it loads older eCShaderDefault class data.
    Angehängte Dateien
    "Unter diesen schwierigen Umständen bin ich mir sicher, daß diese guten Menschen meinen augenblicklichen Bedarf an deren Gold verstehen werden." -- Connor
    NicoDE ist offline Geändert von NicoDE (04.12.2010 um 15:06 Uhr)

  10. #10 Zitieren
    research Avatar von NicoDE
    Registriert seit
    Dec 2004
    Beiträge
    7.409
    There was still the question how the class data is interpreted/used...

    Every shader object has Proxy (eCColorSrcProxy) properties that are resolved by Token to a Shader Element.

    Given the (null)._xmat in the first post this means:
    • ResourceData.Data.ClassData.ColorSrcDiffuse.Token is Valid and the Value is {80926BF2-8465-4C9D-9FAF-87AAB09AB553}
    • Now we iterate over ResourceData.Data.ClassData.eCShaderBase.ShaderEllement[] to look for a valid and matching [].*.eCShaderEllementBase.Token.
    • The first Shader Element matches and is therefore used as Source for the Diffuse Color.
    Note that the Shader Elements also use Proxies with Tokens to resolve properties to Shader Elements, e.g. ResourceData.Data.ClassData.eCShaderBase.ShaderEllement[0].Data.ClassData.TexCoord.eCTexCoordSrcProxy.Token (but the Token is not Valid and therefore does not resolve to a Shader Element).
    "Unter diesen schwierigen Umständen bin ich mir sicher, daß diese guten Menschen meinen augenblicklichen Bedarf an deren Gold verstehen werden." -- Connor
    NicoDE ist offline Geändert von NicoDE (05.12.2010 um 19:09 Uhr)

  11. #11 Zitieren
    Ehrengarde Avatar von Baltram
    Registriert seit
    Jun 2006
    Beiträge
    2.264
    There is one enum in the xmat files I can't find in your enum list: eEShaderMaterialAmbientType. Maybe you could look this up if it's not too time-consuming?
    Baltram ist offline

  12. #12 Zitieren
    research Avatar von NicoDE
    Registriert seit
    Dec 2004
    Beiträge
    7.409
    Looks like a deprecated property that has been introduced with eCShaderDefault version 4 and removed with version 5.
    As of Engine.dll version 1.0.95642.0 the eCShaderDefault class does not have a property named "AmbientLightType".
    If I have some spare time, I’ll have a look at the oldest version available (EFIGS release).
    "Unter diesen schwierigen Umständen bin ich mir sicher, daß diese guten Menschen meinen augenblicklichen Bedarf an deren Gold verstehen werden." -- Connor
    NicoDE ist offline Geändert von NicoDE (07.12.2010 um 13:15 Uhr)

  13. #13 Zitieren
    research Avatar von NicoDE
    Registriert seit
    Dec 2004
    Beiträge
    7.409
    According to the .\data\compiled\effects\shadermaterial\ge_default.fxh:
    // enum
    #define EAmbientLightType_None 0
    #define EAmbientLightType_Simple 1
    #define EAmbientLightType_Complex 2
    The enumeration should look like this:
    Code:
    // eCShaderDefault.AmbientLightType (deprecated)
    enum eEShaderMaterialAmbientType
    {
        eEShaderMaterialAmbientType_None    = 0x00000000,
        eEShaderMaterialAmbientType_Simple  = 0x00000001,
        eEShaderMaterialAmbientType_Complex = 0x00000002
    };
    Good luck

    ps: The XFX_AMBIENTLIGHTTYPE shader macro now depends on the shader version: eCShaderVersionDefault_2_0 set it to 0x00000001 (Simple) and eCShaderVersionDefault_3_0 to 0x00000002 (Complex).
    "Unter diesen schwierigen Umständen bin ich mir sicher, daß diese guten Menschen meinen augenblicklichen Bedarf an deren Gold verstehen werden." -- Connor
    NicoDE ist offline Geändert von NicoDE (07.12.2010 um 13:39 Uhr)

  14. #14 Zitieren
    Ehrengarde Avatar von Baltram
    Registriert seit
    Jun 2006
    Beiträge
    2.264
    Thanks!
    Baltram ist offline

  15. #15 Zitieren
    Ehrengarde Avatar von Baltram
    Registriert seit
    Jun 2006
    Beiträge
    2.264
    Based on the information from this thread, I finished today a small xmat to ASCII converter (as an intermediate result of my work on a xmat editor). There are quite some inaccuracies in expressing the structure but at least it seems to work with every existing xmat: xmat2txt
    Baltram ist offline

  16. #16 Zitieren
    research Avatar von NicoDE
    Registriert seit
    Dec 2004
    Beiträge
    7.409
    Thanks for sharing your tool
    You might have mentioned that the Microsoft Visual C++ 2010 Redistributable Package (x86) is required.

    ps: you should handle empty RawFileExtension values (e.g. in Arch_Temple_Throne_01_Diffuse_01)
    "Unter diesen schwierigen Umständen bin ich mir sicher, daß diese guten Menschen meinen augenblicklichen Bedarf an deren Gold verstehen werden." -- Connor
    NicoDE ist offline Geändert von NicoDE (13.12.2010 um 10:43 Uhr)

  17. #17 Zitieren
    Ehrengarde Avatar von Baltram
    Registriert seit
    Jun 2006
    Beiträge
    2.264
    Zitat Zitat von NicoDE Beitrag anzeigen
    You might have mentioned that the Microsoft Visual C++ 2010 Redistributable Package (x86) is required.
    Oh, I didn't think about that, sorry. Btw, would you recommend me compiling my code in VC++ 2005 rather than 2010?
    Zitat Zitat von NicoDE Beitrag anzeigen
    ps: you should handle empty RawFileExtension values (e.g. in Arch_Temple_Throne_01_Diffuse_01)
    ...so that the output is ".xshmat\0" anyway?
    Baltram ist offline

  18. #18 Zitieren
    research Avatar von NicoDE
    Registriert seit
    Dec 2004
    Beiträge
    7.409
    Zitat Zitat von Baltram Beitrag anzeigen
    Btw, would you recommend me compiling my code in VC++ 2005 rather than 2010?
    I think that this is not important (doesn’t matter) as long as you are not linking against Risen’s Genome libraries and use the exported classes (but I assume it would even work with MSVC 2010).
    The users of your tool can install the MSVC runtimes and can using it - no big problem.

    Zitat Zitat von Baltram Beitrag anzeigen
    ...so that the output is ".xshmat\0" anyway?
    Nothing special, but your text output contains non-printable characters (#0) and some text editors just do not like it
    I don’t know how the raw files (.xshmat) are formatted and what they contain. The import method is not implemented in this resource class... therefore I have no idea how to re-create the raw materials - but with an/your editor there is no need for the raw files...
    "Unter diesen schwierigen Umständen bin ich mir sicher, daß diese guten Menschen meinen augenblicklichen Bedarf an deren Gold verstehen werden." -- Connor
    NicoDE ist offline

  19. #19 Zitieren
    Ranger
    Registriert seit
    Aug 2008
    Beiträge
    174
    Zitat Zitat von NicoDE Beitrag anzeigen
    Some notes about "random" values...
    bCFloatColor streaming seems to be implemented as Read/Write(this, sizeof(*this)). But bCFloatColor has virtual functions. Therefore the implicitly generated member __vftbl is also streamed. This is very dangerous - after reading a bCFloatColor the virtual function table pointer might/will point to the wrong memory location (the virtual functions cannot be safely called anymore).
    Therefore you should set the first pointer to 0 if you generate/modify bCFloatColor.
    When creating your own code not based on game engine (SDK) first four bytes of the bCFloatColor class data in the file should be skipped at all. When using game engine (SDK) to read/write bCFloatColor first 4 bytes and __vftbl are automatically taken into account (__vftbl is saved and restored to a proper value) so no need to worry about it:
    Spoiler:(zum lesen bitte Text markieren)

    Code:
    // virtual bCIStream & operator << ( bCIStream & );
    int __thiscall bCFloatColor__operator__(void *this, int a2)
    {
      int result; // eax@1
      void *v3; // esi@1
      int v4; // ebx@1
    
      v3 = this;
      v4 = *(_DWORD *)this;
      (*(void (__thiscall **)(int, void *, signed int))(*(_DWORD *)a2 + 4))(a2, this, 16);
      result = a2;
      *(_DWORD *)v3 = v4;
      return result;
    }
    PowerGamer ist offline

  20. #20 Zitieren
    research Avatar von NicoDE
    Registriert seit
    Dec 2004
    Beiträge
    7.409
    Thanks for the clarification!

    Using the SharedBase TIL the pseudo code looks like this:
    Code:
    bCIStream *__thiscall bCFloatColor::operator<<(bCFloatColor *this, bCIStream *stream)
    {
      bCFloatColor *self; // esi@1
      const bCColorBase_vftable *vftable; // ebx@1
      bCIStream *result; // eax@1
    
      self = this;
      vftable = this->__vfptr;
      stream->__vfptr->ReadBuffer(stream, this, 0x10u);
      result = stream;
      self->__vfptr = vftable;
      return result;
    }
    NicoDE ist offline

Seite 1 von 2 12 Letzte »

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •