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
28{
29 //! device rests against a fixed bottom tray
31
32 //! device screen assumed to be centered w.r.t. lenses
34
35 //! device rests against a fixed top tray
37};
38
39/*!
40 * These are the values that you need to supply to the distortion code to setup
41 * a @ref u_cardboard_distortion properly.
42 *
43 * @ingroup aux_distortion
44 */
46{
47 float distortion_k[5];
48
49 struct
50 {
51 uint32_t w_pixels, h_pixels;
52 float w_meters, h_meters;
53 } screen;
54
55 //! Distances between the lenses in meters.
57
58 /*!
59 * The distance to the lens from the screen, used to calculate calculate
60 * tanangle of various distances on the screen.
61 */
63
64 /*!
65 * The distance from the tray (the bottom of the screen) to the lens center on the Y axis.
66 */
68
69 //! Fov values that the cardboard configuration has given us.
70 struct xrt_fov fov;
71
72 //! The vertical screen alignment
74};
75
76/*!
77 * Values to create a distortion mesh from cardboard values.
78 *
79 * This matches the formula in the cardboard SDK, while the array is fixed size
80 * setting the K value to zero will make it not have a effect.
81 *
82 * p' = p (1 + K0 r^2 + K1 r^4 + ... + Kn r^(2n))
83 *
84 * @ingroup aux_distortion
85 */
87{
88 //! Cardboard distortion k values.
89 float distortion_k[5];
90
91 struct
92 {
93 //! Used to transform to and from tanangle space.
94 struct xrt_vec2 size;
95 //! Used to transform to and from tanangle space.
97 } screen, texture;
98};
99
100/*!
101 * Both given and derived values needed for cardboard distortion.
102 *
103 * @ingroup aux_distortion
104 */
106{
107 //! Arguments this distortion was created from.
109
110 //! Distortion parameters, some derived from @ref args.
112};
113
114/*!
115 * Take cardboard arguments to turn them into a @ref u_cardboard_distortion and
116 * fill out a @ref xrt_hmd_parts struct.
117 *
118 * @ingroup aux_distortion
119 */
120void
122 struct xrt_hmd_parts *parts,
123 struct u_cardboard_distortion *out_dist);
124
125
126#ifdef __cplusplus
127}
128#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:33
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:46
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:62
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:67
struct xrt_fov fov
Fov values that the cardboard configuration has given us.
Definition: u_distortion.h:70
float inter_lens_distance_meters
Distances between the lenses in meters.
Definition: u_distortion.h:56
enum u_cardboard_vertical_alignment vertical_alignment
The vertical screen alignment.
Definition: u_distortion.h:73
Values to create a distortion mesh from cardboard values.
Definition: u_distortion.h:87
struct xrt_vec2 size
Used to transform to and from tanangle space.
Definition: u_distortion.h:94
float distortion_k[5]
Cardboard distortion k values.
Definition: u_distortion.h:89
struct xrt_vec2 offset
Used to transform to and from tanangle space.
Definition: u_distortion.h:96
Both given and derived values needed for cardboard distortion.
Definition: u_distortion.h:106
struct u_cardboard_distortion_arguments args
Arguments this distortion was created from.
Definition: u_distortion.h:108
struct u_cardboard_distortion_values values[XRT_MAX_VIEWS]
Distortion parameters, some derived from args.
Definition: u_distortion.h:111
Describes a projection matrix fov.
Definition: xrt_defines.h:498
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:267
u_cardboard_vertical_alignment
Definition: u_distortion.h:28
@ U_CARDBOARD_VERTICAL_ALIGNMENT_TOP
device rests against a fixed top tray
Definition: u_distortion.h:36
@ U_CARDBOARD_VERTICAL_ALIGNMENT_CENTER
device screen assumed to be centered w.r.t. lenses
Definition: u_distortion.h:33
@ U_CARDBOARD_VERTICAL_ALIGNMENT_BOTTOM
device rests against a fixed bottom tray
Definition: u_distortion.h:30
Common defines and enums for XRT.