2D Units - shaddatic/sa2b-render-fix GitHub Wiki

The term '2D Units' refers to Ninja's screenspace coordinate system.

It is similar to the Hardware Unit system, but XY coordinates are calculated to screenspace, and Z/depth units match those in the View Unit system.

Assuming the screen definition is set to fill the entire hardware screen, the X and Y position components start at the top left of the screen (0.f, 0.f) and end at the bottom right (640.f, 480.f), and the Z depth component ranges from the front of the screen (0.f) to the back of the screen (-infinity).

In other words:

  • X = (0~Screen Size X, left~right)
  • Y = (0~Screen Size Y, top~bottom)
  • Z = (0~-infinity, front~back)

Unlike Hardware Units, 2D units may be clipped to the near and far planes; which are usually -1.f~-65536.f. Additionally, depth values > -1.f are clamped to -1.f.