Texture2D Handler - thethiny/NRS-Asset-Manager GitHub Wiki

Texture2D Handler

Extracts texture data from Texture2D exports, including external bulk data from TFC/PSF files.

Architecture Differences

MK11

  • Texture metadata parsed via UE3 properties
  • Bulk data located through centralized PSF tables using CookedBulkDataOwnerKey
  • PSF data pre-dumped to disk during dump_psfs(), then texture handler reads from files
  • Uses bc7.py for DDS header generation and PNG conversion

IJ2

  • Texture metadata parsed via UE3 properties (includes TextureFileCacheName)
  • Mip data structure parsed inline after properties
  • TFC data read on-demand via IJ2Archive.deserialize_block()
  • Supports mixed inline + external mips (large mips in TFC, small mips inline)

IJ2 Mip Data Structure

After UE3 properties end (None sentinel), the Texture2D export contains:

Header (0x3C bytes):
  padding, unknown offsets, mip_count(u32)

Per Mip (variable size):
  flags(u32)           — bit 0: external (TFC), 0: inline
  element_count(u32)   — uncompressed data size
  size_on_disk(u64)    — compressed size (TFC) or same as element_count (inline)
  offset_in_file(u64)  — offset in TFC or absolute offset in UPK
  [inline_data]        — raw bytes if flags==0
  width(u32)
  height(u32)

Supported Pixel Formats

Format DXGI Type
PF_DXT1 71 (BC1_UNORM) Block compressed
PF_DXT3 74 (BC2_UNORM) Block compressed
PF_DXT5 77 (BC3_UNORM) Block compressed
PF_BC4 80 (BC4_UNORM) Block compressed
PF_BC5 83 (BC5_UNORM) Block compressed
PF_BC6 95 (BC6H_UF16) Block compressed
PF_BC7 98 (BC7_UNORM) Block compressed
PF_G8 61 (R8_UNORM) Per-pixel
PF_A8R8G8B8 28 (R8G8B8A8_UNORM) Per-pixel
PF_V8U8 118 (R8G8_SNORM) Per-pixel

Output

  • .dds — DirectDraw Surface with DX10 header, all mip levels
  • .png — Decoded from the largest mip (BC formats via dds library)
  • .json — Texture metadata (format, dimensions, mip info)