Monado OpenXR Runtime
u_distortion.h
Go to the documentation of this file.
1// Copyright 2020, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Code to handle distortion parameters and fov.
6 * @author Jakob Bornecrantz <jakob@collabora.com>
7 * @ingroup aux_distortion
8 */
9
10#pragma once
11
12#include "xrt/xrt_defines.h"
13
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19
20struct xrt_hmd_parts;
21
22/*!
23 * @defgroup aux_distortion Distortion utilities
24 * @ingroup aux_util
25 */
26
27/*!
28 * These are the values that you need to supply to the distortion code to setup
29 * a @ref u_cardboard_distortion properly.
30 *
31 * @ingroup aux_distortion
32 */
34{
35 float distortion_k[5];
36
37 struct
38 {
39 uint32_t w_pixels, h_pixels;
40 float w_meters, h_meters;
41 } screen;
42
43 //! Distances between the lenses in meters.
45
46 /*!
47 * The distance to the lens from the screen, used to calculate calculate
48 * tanangle of various distances on the screen.
49 */
51
52 /*!
53 * The distance from the tray (the bottom of the screen) to the lens center on the Y axis.
54 */
56
57 //! Fov values that the cardboard configuration has given us.
58 struct xrt_fov fov;
59};
60
61/*!
62 * Values to create a distortion mesh from cardboard values.
63 *
64 * This matches the formula in the cardboard SDK, while the array is fixed size
65 * setting the K value to zero will make it not have a effect.
66 *
67 * p' = p (1 + K0 r^2 + K1 r^4 + ... + Kn r^(2n))
68 *
69 * @ingroup aux_distortion
70 */
72{
73 //! Cardboard distortion k values.
74 float distortion_k[5];
75
76 struct
77 {
78 //! Used to transform to and from tanangle space.
79 struct xrt_vec2 size;
80 //! Used to transform to and from tanangle space.
82 } screen, texture;
83};
84
85/*!
86 * Both given and derived values needed for cardboard distortion.
87 *
88 * @ingroup aux_distortion
89 */
91{
92 //! Arguments this distortion was created from.
94
95 //! Distortion parameters, some derived from @ref args.
97};
98
99/*!
100 * Take cardboard arguments to turn them into a @ref u_cardboard_distortion and
101 * fill out a @ref xrt_hmd_parts struct.
102 *
103 * @ingroup aux_distortion
104 */
105void
107 struct xrt_hmd_parts *parts,
108 struct u_cardboard_distortion *out_dist);
109
110
111#ifdef __cplusplus
112}
113#endif
void u_distortion_cardboard_calculate(const struct u_cardboard_distortion_arguments *args, struct xrt_hmd_parts *parts, struct u_cardboard_distortion *out_dist)
Take cardboard arguments to turn them into a u_cardboard_distortion and fill out a xrt_hmd_parts stru...
Definition: u_distortion.c:21
Helper struct to make code easier to read.
Definition: render_distortion.c:183
These are the values that you need to supply to the distortion code to setup a u_cardboard_distortion...
Definition: u_distortion.h:34
float screen_to_lens_distance_meters
The distance to the lens from the screen, used to calculate calculate tanangle of various distances o...
Definition: u_distortion.h:50
float tray_to_lens_distance_meters
The distance from the tray (the bottom of the screen) to the lens center on the Y axis.
Definition: u_distortion.h:55
struct xrt_fov fov
Fov values that the cardboard configuration has given us.
Definition: u_distortion.h:58
float inter_lens_distance_meters
Distances between the lenses in meters.
Definition: u_distortion.h:44
Values to create a distortion mesh from cardboard values.
Definition: u_distortion.h:72
struct xrt_vec2 size
Used to transform to and from tanangle space.
Definition: u_distortion.h:79
float distortion_k[5]
Cardboard distortion k values.
Definition: u_distortion.h:74
struct xrt_vec2 offset
Used to transform to and from tanangle space.
Definition: u_distortion.h:81
Both given and derived values needed for cardboard distortion.
Definition: u_distortion.h:91
struct u_cardboard_distortion_arguments args
Arguments this distortion was created from.
Definition: u_distortion.h:93
struct u_cardboard_distortion_values values[XRT_MAX_VIEWS]
Distortion parameters, some derived from args.
Definition: u_distortion.h:96
Describes a projection matrix fov.
Definition: xrt_defines.h:486
All of the device components that deals with interfacing to a users head.
Definition: xrt_device.h:92
A 2 element vector with single floats.
Definition: xrt_defines.h:250
Common defines and enums for XRT.