The open source OpenXR runtime
1// Copyright 2025, Beyley Cardellio
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Public functions for the Oculus Rift distortion correction.
6 * @author Beyley Cardellio <ep1cm1n10n123@gmail.com>
7 * @ingroup drv_rift
8 */
9
10#include "rift_interface.h"
11
12struct rift_distortion_render_info
13{
14 struct rift_lens_distortion *distortion;
15 struct xrt_vec2 lens_center;
16 struct xrt_vec2 tan_eye_angle_scale;
17 struct xrt_vec2 pixels_per_tan_angle_at_center;
18};
19
20struct rift_distortion_render_info
21rift_get_distortion_render_info(struct rift_hmd *hmd, uint32_t view);
22
23struct xrt_vec3
24rift_distortion_distance_scale_squared_split_chroma(struct rift_lens_distortion *lens_distortion,
25 float distance_squared);
26
27struct rift_viewport_fov_tan
28rift_calculate_fov_from_hmd(struct rift_hmd *hmd, struct rift_distortion_render_info *distortion, uint32_t view);
29
30struct rift_scale_and_offset
31rift_calculate_ndc_scale_and_offset_from_fov(struct rift_viewport_fov_tan *fov);
32
33struct rift_scale_and_offset
34rift_calculate_uv_scale_and_offset_from_ndc_scale_and_offset(struct rift_scale_and_offset eye_to_source_ndc);
35
36void
37rift_fill_in_default_distortions(struct rift_hmd *hmd);
38
39xrt_result_t
40rift_hmd_compute_distortion(struct xrt_device *dev, uint32_t view, float u, float v, struct xrt_uv_triplet *out_result);