glTF Perspective Camera Projection Parameters
In glTF (GL Transmission Format), a camera node defines a perspective
projection by referencing a reusable perspective camera object stored in
the asset's root arrays. This article explains how glTF separates
spatial transformation from camera optics, details the specific
parameters within the perspective property—including
vertical field of view, clipping planes, and aspect ratio—and shows how
these values construct standard projection matrices.
Separation of Nodes and Camera Definitions
glTF separates the camera's spatial position from its optical characteristics:
- The Node: Defines the camera's transform
(translation, rotation, and scale) in the 3D scene graph. A node points
to a camera by its index in the root
camerasarray using the"camera"property. - The Camera Object: Defines the projection math. It
resides in the top-level
"cameras"array and specifies a"type"(set to"perspective") and a"perspective"object containing the projection parameters.
By default, a glTF camera looks down its local negative Z-axis
(-Z), with the local Y-axis pointing up (+Y)
and the local X-axis pointing right (+X).
Perspective Camera Properties
Inside the "perspective" object, glTF defines four core
attributes:
{
"cameras": [
{
"type": "perspective",
"perspective": {
"aspectRatio": 1.5,
"yfov": 0.785398,
"zfar": 100.0,
"znear": 0.1
}
}
],
"nodes": [
{
"camera": 0,
"translation": [0.0, 1.0, 5.0]
}
]
}yfov(Float, Required): The vertical Field of View specified in radians. For example, a 45-degree vertical FOV is represented as roughly0.785398radians. glTF uses vertical FOV rather than horizontal FOV as the primary metric, matching common graphics API conventions.znear(Float, Required): The distance from the camera origin to the near clipping plane along the negative Z-axis. This value must strictly be greater than zero (znear > 0) to prevent division-by-zero errors in perspective divide operations.zfar(Float, Optional): The distance from the camera origin to the far clipping plane along the negative Z-axis. When present, it must be greater thanznear. If omitted, the camera defines an infinite perspective projection, where the far plane extends indefinitely.aspectRatio(Float, Optional): The aspect ratio of the viewport, defined as width divided by height (width / height). This property is optional; if omitted, the rendering engine dynamically computes the aspect ratio from the display canvas dimensions.
Matrix Derivation
When a runtime engine parses these parameters, it computes a standard right-handed perspective projection matrix:
- Horizontal Field of View: Computed as
xfov = 2 * atan(tan(yfov / 2) * aspectRatio). - Finite Projection: When
zfaris present, the matrix mapsznearandzfarto standard normalized device coordinates (typically[-1, 1]or[0, 1]depending on the graphics backend like WebGL, Vulkan, or DirectX). - Infinite Projection: When
zfaris undefined, the engine uses the infinite perspective projection formulation, avoiding depth-buffer precision issues at extreme distances.