Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra Surface Data Format Research #49

Open
yretenai opened this issue Oct 31, 2021 · 1 comment
Open

Extra Surface Data Format Research #49

yretenai opened this issue Oct 31, 2021 · 1 comment

Comments

@yretenai
Copy link

NOT in the file header, this describes the format found in most games that specify extra data size 0xC (12) to 0x14 (16)

enum g1t_colorspace_t : uint8_t {
  G1T_COLORSPACE_LINEAR = 0,
  G1T_COLORSPACE_SRGB = 1
}

struct extra_data_t {
  uint32_t size; // 12, 16, or 20.
  float unk1; // assumption is depth, usually 0. some have it set to between 0.5 and 10.
  uint8_t unk2;
  uint8_t unk3;
  uint8_t unk4;
  g1t_colorspace_t colorspace; // bit flag?
  // if size >= 16
  int32_t ex_width; // if width is large enough to overflow bits in bit packing
  // if size >= 20
  int32_t ex_height; // if height is large enough to overflow bits in bit packing
};

the colorspace byte is used to determine if the surface is decoded in linear or sRGB colorspace.

@VitaSmith
Copy link
Owner

VitaSmith commented Dec 5, 2021

Here are my findings on this:

If we treat the data right after the depth as a 32-bit word in big-endian format (it always seems to be big endian), then we have:

  • bit 0: Seems to be a marker for textures that are being directly mapped to a surface (for instance normal maps or overlays will not have this flag set). As far as I could see, the SRGB flag is part of the main flags from the common texture header, and not the extended data. But since this is still guesswork, I can't be completely positive on this.
  • bits 16-21 / 28-31: These contain the number of textures for a texture array (DirectX 10 or later). Bits 28-31 are the low part and 16-21 are the high part. For instance a texture with 128 (= 0x80) frames (yes, I have seen one of those) would have 0x0008xxxx and a texture with 2 frames would have 0x2000xxxx. You can find a textures with multiple frames in Blue Reflection: Second Light in the pc000_scl model for instance. I am not sure if bits 22-27 are also meant to be used for texture array dimensions, or for something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants