doc.odin 5.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Implementation of the HxA 3D asset format
  2. // HxA is a interchangeable graphics asset format.
  3. // Designed by Eskil Steenberg. @quelsolaar / eskil 'at' obsession 'dot' se / www.quelsolaar.com
  4. //
  5. // Author of this Odin package: Ginger Bill
  6. //
  7. // Following comment is copied from the original C-implementation
  8. // ---------
  9. // -Does the world need another Graphics file format?
  10. // Unfortunately, Yes. All existing formats are either too large and complicated to be implemented from
  11. // scratch, or don't have some basic features needed in modern computer graphics.
  12. // -Who is this format for?
  13. // For people who want a capable open Graphics format that can be implemented from scratch in
  14. // a few hours. It is ideal for graphics researchers, game developers or other people who
  15. // wants to build custom graphics pipelines. Given how easy it is to parse and write, it
  16. // should be easy to write utilities that process assets to preform tasks like: generating
  17. // normals, light-maps, tangent spaces, Error detection, GPU optimization, LOD generation,
  18. // and UV mapping.
  19. // -Why store images in the format when there are so many good image formats already?
  20. // Yes there are, but only for 2D RGB/RGBA images. A lot of computer graphics rendering rely
  21. // on 1D, 3D, cube, multilayer, multi channel, floating point bitmap buffers. There almost no
  22. // formats for this kind of data. Also 3D files that reference separate image files rely on
  23. // file paths, and this often creates issues when the assets are moved. By including the
  24. // texture data in the files directly the assets become self contained.
  25. // -Why doesn't the format support <insert whatever>?
  26. // Because the entire point is to make a format that can be implemented. Features like NURBSs,
  27. // Construction history, or BSP trees would make the format too large to serve its purpose.
  28. // The facilities of the formats to store meta data should make the format flexible enough
  29. // for most uses. Adding HxA support should be something anyone can do in a days work.
  30. // Structure:
  31. // ----------
  32. // HxA is designed to be extremely simple to parse, and is therefore based around conventions. It has
  33. // a few basic structures, and depending on how they are used they mean different things. This means
  34. // that you can implement a tool that loads the entire file, modifies the parts it cares about and
  35. // leaves the rest intact. It is also possible to write a tool that makes all data in the file
  36. // editable without the need to understand its use. It is also possible for anyone to use the format
  37. // to store data axillary data. Anyone who wants to store data not covered by a convention can submit
  38. // a convention to extend the format. There should never be a convention for storing the same data in
  39. // two differed ways.
  40. // The data is story in a number of nodes that are stored in an array. Each node stores an array of
  41. // meta data. Meta data can describe anything you want, and a lot of conventions will use meta data
  42. // to store additional information, for things like transforms, lights, shaders and animation.
  43. // Data for Vertices, Corners, Faces, and Pixels are stored in named layer stacks. Each stack consists
  44. // of a number of named layers. All layers in the stack have the same number of elements. Each layer
  45. // describes one property of the primitive. Each layer can have multiple channels and each layer can
  46. // store data of a different type.
  47. // HaX stores 3 kinds of nodes
  48. // - Pixel data.
  49. // - Polygon geometry data.
  50. // - Meta data only.
  51. // Pixel Nodes stores pixels in a layer stack. A layer may store things like Albedo, Roughness,
  52. // Reflectance, Light maps, Masks, Normal maps, and Displacement. Layers use the channels of the
  53. // layers to store things like color. The length of the layer stack is determined by the type and
  54. // dimensions stored in the
  55. // Geometry data is stored in 3 separate layer stacks for: vertex data, corner data and face data. The
  56. // vertex data stores things like verities, blend shapes, weight maps, and vertex colors. The first
  57. // layer in a vertex stack has to be a 3 channel layer named "position" describing the base position
  58. // of the vertices. The corner stack describes data per corner or edge of the polygons. It can be used
  59. // for things like UV, normals, and adjacency. The first layer in a corner stack has to be a 1 channel
  60. // integer layer named "index" describing the vertices used to form polygons. The last value in each
  61. // polygon has a negative - 1 index to indicate the end of the polygon.
  62. // Example:
  63. // A quad and a tri with the vertex index:
  64. // [0, 1, 2, 3] [1, 4, 2]
  65. // is stored:
  66. // [0, 1, 2, -4, 1, 4, -3]
  67. // The face stack stores values per face. the length of the face stack has to match the number of
  68. // negative values in the index layer in the corner stack. The face stack can be used to store things
  69. // like material index.
  70. // Storage
  71. // -------
  72. // All data is stored in little endian byte order with no padding. The layout mirrors the structs
  73. // defined below with a few exceptions. All names are stored as a 8-bit unsigned integer indicating
  74. // the length of the name followed by that many characters. Termination is not stored in the file.
  75. // Text strings stored in meta data are stored the same way as names, but instead of a 8-bit unsigned
  76. // integer a 32-bit unsigned integer is used.
  77. package encoding_hxa