{
  "schema": "imperivm-format-article/v1",
  "language": "en",
  "scope": "Imperivm HD",
  "status": "partial",
  "slug": "terrain-grids",
  "title": "GRID · terrain layers",
  "summary": "Binary grid family with a shared 20-byte header. Each layer has its own cell size and bit depth.",
  "sections": [
    {
      "id": "purpose",
      "title": "One map, several grids",
      "paragraphs": [
        "The map uses separate layers for terrain, height, lighting, transitions, decoration and passability. They share a header but are not interchangeable.",
        "The visible signature in the first four file bytes is DIRG. GRID names the format family; writing literal GRID as the signature would produce different bytes."
      ]
    },
    {
      "id": "header",
      "title": "Shared header",
      "table": {
        "columns": [
          "Byte position",
          "Type",
          "Field"
        ],
        "rows": [
          [
            "0",
            "4 bytes",
            "ASCII signature DIRG"
          ],
          [
            "4",
            "uint32 LE",
            "cell_size: cell dimension"
          ],
          [
            "8",
            "uint32 LE",
            "bits_per_cell: bits per cell"
          ],
          [
            "12",
            "uint32 LE",
            "width: logical width"
          ],
          [
            "16",
            "uint32 LE",
            "height: logical height"
          ]
        ]
      },
      "paragraphs": [
        "LE means little-endian. Layer data follows the 20-byte header. Width and height are logical dimensions, not directly the number of cell columns and rows."
      ]
    },
    {
      "id": "layers",
      "title": "Per-layer values",
      "table": {
        "columns": [
          "File",
          "cell_size",
          "bits_per_cell"
        ],
        "rows": [
          [
            "Terrain.terrain.grid",
            "64",
            "8"
          ],
          [
            "Terrain.height.grid",
            "32",
            "8"
          ],
          [
            "Terrain.light.grid",
            "32",
            "8"
          ],
          [
            "Terrain.trans.grid",
            "64",
            "4"
          ],
          [
            "Terrain.decor.grid",
            "64",
            "16"
          ],
          [
            "Terrain.pass.grid",
            "16",
            "1"
          ]
        ]
      },
      "paragraphs": [
        "For dimensions divisible by cell_size, divide width and height by that value to obtain cell columns and rows. These values belong to each variant; changing the header's bit depth does not automatically convert its data.",
        "The passability variant uses one bit per 16-unit cell. Entity footprint .pass files share that header and variant, even though their dimensions and use differ."
      ]
    },
    {
      "id": "limits",
      "title": "Known limits",
      "paragraphs": [
        "The header alone does not fully explain terrain, height, lighting or decoration values. This entry also does not specify every layer's packing, alignment or bit-order details.",
        "Do not infer height ranges, lighting units, index meanings or supported map sizes from the cell type alone."
      ]
    }
  ]
}