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 //! Where on the y axis the center of the lens is on the screen.
48
49 /*!
50 * The distance to the lens from the screen, used to calculate calculate
51 * tanangle of various distances on the screen.
52 */
54
55 //! Fov values that the cardboard configuration has given us.
56 struct xrt_fov fov;
57};
58
59/*!
60 * Values to create a distortion mesh from cardboard values.
61 *
62 * This matches the formula in the cardboard SDK, while the array is fixed size
63 * setting the K value to zero will make it not have a effect.
64 *
65 * p' = p (1 + K0 r^2 + K1 r^4 + ... + Kn r^(2n))
66 *
67 * @ingroup aux_distortion
68 */
70{
71 //! Cardboard distortion k values.
72 float distortion_k[5];
73
74 struct
75 {
76 //! Used to transform to and from tanangle space.
77 struct xrt_vec2 size;
78 //! Used to transform to and from tanangle space.
80 } screen, texture;
81};
82
83/*!
84 * Both given and derived values needed for cardboard distortion.
85 *
86 * @ingroup aux_distortion
87 */
89{
90 //! Arguments this distortion was created from.
92
93 //! Distortion parameters, some derived from @ref args.
95};
96
97/*!
98 * Take cardboard arguments to turn them into a @ref u_cardboard_distortion and
99 * fill out a @ref xrt_hmd_parts struct.
100 *
101 * @ingroup aux_distortion
102 */
103void
105 struct xrt_hmd_parts *parts,
106 struct u_cardboard_distortion *out_dist);
107
108
109#ifdef __cplusplus
110}
111#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:20
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:53
struct xrt_fov fov
Fov values that the cardboard configuration has given us.
Definition: u_distortion.h:56
float lens_y_center_on_screen_meters
Where on the y axis the center of the lens is on the screen.
Definition: u_distortion.h:47
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:70
struct xrt_vec2 size
Used to transform to and from tanangle space.
Definition: u_distortion.h:77
float distortion_k[5]
Cardboard distortion k values.
Definition: u_distortion.h:72
struct xrt_vec2 offset
Used to transform to and from tanangle space.
Definition: u_distortion.h:79
Both given and derived values needed for cardboard distortion.
Definition: u_distortion.h:89
struct u_cardboard_distortion_arguments args
Arguments this distortion was created from.
Definition: u_distortion.h:91
struct u_cardboard_distortion_values values[XRT_MAX_VIEWS]
Distortion parameters, some derived from args.
Definition: u_distortion.h:94
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:90
A 2 element vector with single floats.
Definition: xrt_defines.h:250
Common defines and enums for XRT.