Skip to main content

GR2

This document describes the GR2 file format used in the Ragnarok Online client.

Contents

GR2 files are binary data stores created by the proprietary Granny3D SDK. They contain the following:

  • 3D mesh geometry and textures for the WoE guardians, emperium, treasure box, and guild flag
  • Skeletons and pose animations for the above models (in separate files, one per model and pose)
  • Some leftover (unfinished) data for a potential 3D Novice-class player character

Although the format is widely used in the games industry, only the specific version used in RO is referenced here.

Layout

The layout is quite complex and has been described elsewhere:

  • A great description is found at the OpenGR2 wiki, which contains many details worth reading
  • The previous version of this documentation is still available (warning: may contain inaccuracies and errors)
  • Alternate implementations exist on GitHub, several of which are listed in the above document

As of 2023, there appears to be no third-party implementation that doesn't rely on the granny2.dll in at least some way.

Oodle Compression

This is just a quick correction to the original article, which mentions the use of Huffman tables.

According to this blog comment by Fabian Giesen (of RAD), Oodle-0 is actually using a standard Lempel-Ziv-77 compressor combined with a (presumably adaptive) arithmetic encoder. Indeed it appears that the compressed GR2 segments are fed into the AE decoder and then the LZ decompressor, though the specifics of how the arithmetic coding works aren't exactly clear.

Data Segments

All GR2 files are split into multiple segments, which can be individually compressed. Cursory data analysis yields:

  • The first segments is always large (and often the largest), presumably containing the bulk of the data tree
  • Segments two, three, four, and five likely contain the geometry as they're absent from RO skeletons
  • Segments two and three are always used together; the same goes for four and five (hinting at related data)
  • Segment two is always larger than three, and segment four is always larger than five - which hints at vertices/indices
  • A reasonable guess is that those are just vertex positions, indices, normals, etc., split according to statistical properties
  • The last segment is large and always uncompressed, probably containing the (already-compressed) textures

It's been reported that other games may use more segments (unverified claim), but in RO there are always six.

Data Tracks

Oodle-0 compressed segments consist of multiple data tracks, which are defined by the start and end offset, as well as certain compressor settings. The range (from and to) is defined in the segment header, while compression parameters and inputs for the arithmetic decoder can be found at the start of each compressed segment. More research is needed on these parameters.

See also

Here's a few resources that might help with understanding the Oodle decompression: