Skip to content

Instantly share code, notes, and snippets.

View CodyJasonBennett's full-sized avatar

Cody Bennett CodyJasonBennett

View GitHub Profile
@wiseConst
wiseConst / 3_byte_tangent_frames.md
Last active June 17, 2025 05:59
3 BYTE TANGENT FRAMES + bitmask array for TBN sign. Doom Eternal 2020

3-Byte Tangent Frame Encoding (Doom Eternal 2020)

This method stores a full TBN frame using just 3 bytes per vertex (plus a bitfield), instead of the traditional 28 bytes (normal: vec3, tangent: vec4). It leverages octahedral encoding for normals and a rotation angle for tangent reconstruction.

Motivation

Storing both glm::vec3 normal and glm::vec4 tangent is costly. Since the bitangent can be reconstructed via a cross product, we only need:

  • A unit normal (encoded in 2 bytes)
  • An angle to rotate a base tangent around the normal (1 byte)