Skip to content

Engine → Renderer

camera.h

Cameras and projection helpers. Every projection is reverse-Z: the near plane maps to depth 1 and the far plane to depth 0, for perspective and orthographic cameras alike, so a single GreaterOrEqual depth test serves every pass.

Structs

File Description
camera

Enumerations

projection_type

enum class projection_type : u8 {
    PERSPECTIVE = 0,
    ORTHOGRAPHIC
};

Functions

Public

clip_from_view

[[nodiscard]] CONJURE_API math::mat4 clip_from_view(
    const camera &camera,
    f32 aspectRatio) noexcept;

Reverse-Z projection: near maps to depth 1, far to depth 0, for both projection types. A non-positive aspect ratio, near plane or field of view, or a far plane at or before the near plane, asserts and yields the identity.

frustum_from_clip

[[nodiscard]] CONJURE_API math::frustum frustum_from_clip(
    const math::mat4 &clipFromWorld) noexcept;

The inward-facing frustum planes of a clip-from-world matrix (reverse-Z aware: the near plane is the one at depth 1).

ray_from_viewport

[[nodiscard]] CONJURE_API math::ray ray_from_viewport(
    const camera &camera,
    const math::mat4 &worldFromView,
    math::vec2 viewportUv,
    f32 aspectRatio) noexcept;

The world-space ray through a viewport position given in [0, 1] x [0, 1] (origin top-left, y down). The ray starts on the near plane; for a perspective camera it passes through the eye. The aspect ratio is the viewport's width over height (a non-square viewport requires the aspect ratio for unprojection).

to_string

[[nodiscard]] CONJURE_API std::string_view to_string(
    projection_type type) noexcept;

The enumerator name of a projection type ("PERSPECTIVE").