Monado OpenXR Runtime
Loading...
Searching...
No Matches
u_distortion_mesh_rift.c File Reference

Rift-style lens distortion, as used by the Oculus Rift DK2 and CV1. More...

#include "math/m_api.h"
#include "math/m_vec2.h"
#include "u_distortion_mesh.h"
Include dependency graph for u_distortion_mesh_rift.c:

Data Structures

struct  u_rift_distortion_render_info
 
struct  u_rift_distortion_tan_fov
 
struct  u_rift_distortion_scale_offset
 

Functions

static struct xrt_vec2 to_tan_angle (const struct u_rift_distortion_render_info *info, struct xrt_vec2 ndc)
 Computes the tan angle of a NDC point, as seen from the eye.
 
static float value_at (const float *k, int j)
 Value of the curve at knot j.
 
static float slope_after (const float *k, int n, int j)
 Slope the curve leaves knot j with.
 
static float slope_before (const float *k, int n, int j)
 Slope the curve arrives at knot j with.
 
static float hermite (float p0, float m0, float p1, float m1, float t)
 Standard cubic Hermite: value p0 with slope m0 at t=0, value p1 with slope m1 at t=1.
 
static float curve (const float *k, int n, float s)
 Magnification at curve position s.
 
static float magnification (const struct u_rift_eye_profile *profile, float rho)
 The magnification for a squared tan-angle radius.
 
static struct u_rift_distortion_render_info compute_render_info (const struct u_rift_panel *panel, const struct u_rift_eye_profile *profile, uint32_t view)
 
static struct u_rift_distortion_tan_fov fov_from_eye (float lens_diameter, float eye_relief, float rot_rad)
 Computes the tangent FOV for an eye from the given parameters.
 
static float physical_fov_sweep (const struct u_rift_distortion_render_info *info, const struct u_rift_eye_profile *profile, const struct xrt_vec2 edge, int axis, float sign)
 Walk from the lens centre to edge, and return how far the view reaches in one direction.
 
static struct u_rift_distortion_tan_fov physical_fov (const struct u_rift_distortion_render_info *info, const struct u_rift_eye_profile *profile)
 
static struct u_rift_distortion_tan_fov fov (const struct u_rift_panel *panel, const struct u_rift_eye_profile *profile, const struct u_rift_distortion_render_info *info)
 
static struct u_rift_distortion_scale_offset ndc_mapping (const struct u_rift_distortion_tan_fov *fov)
 
static struct u_rift_distortion_scale_offset uv_mapping (const struct u_rift_distortion_scale_offset ndc)
 
static void colour_fringing_scales (const struct u_rift_eye_profile *profile, float rho, float *scales)
 
void u_compute_distortion_rift (const struct u_rift_panel *panel, const struct u_rift_eye_profile *profile, uint32_t view, float u, float v, struct xrt_uv_triplet *result)
 Oculus Rift distortion implementation.
 

Detailed Description

Rift-style lens distortion, as used by the Oculus Rift DK2 and CV1.

Author
Beyley Cardellio ep1cm.nosp@m.1n10.nosp@m.n123@.nosp@m.gmai.nosp@m.l.com

Function Documentation

◆ curve()

static float curve ( const float *  k,
int  n,
float  s 
)
static

Magnification at curve position s.

References CLAMP, hermite(), slope_after(), slope_before(), and value_at().

◆ fov_from_eye()

static struct u_rift_distortion_tan_fov fov_from_eye ( float  lens_diameter,
float  eye_relief,
float  rot_rad 
)
static

Computes the tangent FOV for an eye from the given parameters.

Parameters
lens_diameterThe diameter of the lens.
eye_reliefThe eye relief of the lens.
rot_radThe rotation of the eye, in radians. Max 30 degrees.

References CLAMP, DEG_TO_RAD, and MAX.

◆ hermite()

static float hermite ( float  p0,
float  m0,
float  p1,
float  m1,
float  t 
)
static

Standard cubic Hermite: value p0 with slope m0 at t=0, value p1 with slope m1 at t=1.

Any equivalent arrangement of these terms will do.

Referenced by curve().

◆ magnification()

static float magnification ( const struct u_rift_eye_profile profile,
float  rho 
)
static

The magnification for a squared tan-angle radius.

References u_rift_eye_profile::k, u_rift_eye_profile::k_count, and u_rift_eye_profile::max_r.

Referenced by physical_fov_sweep().

◆ physical_fov_sweep()

static float physical_fov_sweep ( const struct u_rift_distortion_render_info info,
const struct u_rift_eye_profile profile,
const struct xrt_vec2  edge,
int  axis,
float  sign 
)
static

Walk from the lens centre to edge, and return how far the view reaches in one direction.

axis picks x or y; sign is -1 for the left and up directions, which run towards negative tan-angle.

References magnification(), MAX, and to_tan_angle().

◆ slope_after()

static float slope_after ( const float *  k,
int  n,
int  j 
)
static

Slope the curve leaves knot j with.

Referenced by curve(), and slope_before().

◆ slope_before()

static float slope_before ( const float *  k,
int  n,
int  j 
)
static

Slope the curve arrives at knot j with.

Same as slopeAfter everywhere except knot n-2; see section 5.3.

References slope_after().

Referenced by curve().

◆ to_tan_angle()

static struct xrt_vec2 to_tan_angle ( const struct u_rift_distortion_render_info info,
struct xrt_vec2  ndc 
)
inlinestatic

Computes the tan angle of a NDC point, as seen from the eye.

Referenced by physical_fov_sweep(), and u_compute_distortion_rift().

◆ u_compute_distortion_rift()

void u_compute_distortion_rift ( const struct u_rift_panel panel,
const struct u_rift_eye_profile profile,
uint32_t  view,
float  u,
float  v,
struct xrt_uv_triplet result 
)

Oculus Rift distortion implementation.

References u_rift_eye_profile::k_count, and to_tan_angle().

◆ value_at()

static float value_at ( const float *  k,
int  j 
)
static

Value of the curve at knot j.

Referenced by curve().