//------------------------------------------------ //--- 010 Editor v13.0.1 Binary Template // // File: GNF.bt // Authors: avan // Version: 0.9 // Purpose: Parse PS4 GNF texture file // Category: Game // File Mask: *.gnf // ID Bytes: 47 4E 46 20 F8 // History: // 0.9 2023-04-12 avan: Initial release. // // More information available at // https://github.com/tge-was-taken/GFD-Studio // https://en.wikipedia.org/wiki/Z-order_curve //------------------------------------------------ RequiresVersion( 12 ); typedef struct Header { char magic[4] ; uint32 contentSize ; byte version ; byte textureCount ; byte alligment ; byte unused ; uint32 streamSize ; }; typedef struct TextureDesc { typedef struct MWord1 { local int64 pos = FTell(); local uint32 value = ReadUInt(); FSeek(pos); uint32 MinLodClamp > 8))>; FSeek(pos); uint32 SurfaceFormat > 20))>; FSeek(pos); uint32 ChannelType >26))>; }; typedef struct MWord2 { local int64 pos = FTell(); local uint32 value = ReadUInt(); FSeek(pos); uint32 Width ; FSeek(pos); uint32 Height > 14) + 1)>; FSeek(pos); uint32 SamplerModulationFactor >28))>; }; typedef struct MWord3 { local int64 pos = FTell(); local uint32 value = ReadUInt(); FSeek(pos); uint32 ChannelOrderX ; FSeek(pos); uint32 ChannelOrderY > 3))>; FSeek(pos); uint32 ChannelOrderZ > 6))>; FSeek(pos); uint32 ChannelOrderW > 9))>; FSeek(pos); uint32 BaseMipLevel >12))>; FSeek(pos); uint32 LastMipLevel >16))>; FSeek(pos); uint32 TileMode >20))>; FSeek(pos); uint32 IsPaddedToPow2 >25))>; FSeek(pos); uint32 TextureType >28))>; }; typedef struct MWord4 { local int64 pos = FTell(); local uint32 value = ReadUInt(); FSeek(pos); uint32 Depth ; FSeek(pos); uint32 Pitch > 13) + 1)>; }; typedef struct MWord5 { local int64 pos = FTell(); local uint32 value = ReadUInt(); FSeek(pos); uint32 BaseArraySliceIndex ; FSeek(pos); uint32 LastArraySliceIndex > 13)>; }; typedef struct MWord6 { local int64 pos = FTell(); local uint32 value = ReadUInt(); FSeek(pos); uint32 MinLodWarning ; FSeek(pos); uint32 MipStatsCounterIndex > 12))>; FSeek(pos); uint32 MipStatsEnabled >20))>; FSeek(pos); uint32 MetadataCompressionEnabled >21))>; FSeek(pos); uint32 DccAlphaOnMsb >22))>; FSeek(pos); uint32 DccColorTransform >23))>; FSeek(pos); uint32 UseAltTileMode >24))>; }; uint32 mWord0 ; MWord1 mWord1 ; MWord2 mWord2 ; MWord3 mWord3 ; MWord4 mWord4 ; MWord5 mWord5 ; MWord6 mWord6 ; uint32 metadataOffset ; }; typedef struct StreamBlock (uint32 dataCount) { typedef struct Data { byte data[16]; }; local uint index = 0; while (index++ < dataCount) Data data ; }; //======================= Main Program ======================= Header header ; TextureDesc textureDesc ; local uint32 dataSize = header.streamSize - header.contentSize - 8; FSeek(header.contentSize+8); StreamBlock streamBlock(dataSize/16) ;