mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 12:46:12 +00:00
u/distortion: A stab in the dark to try and improve Index chromatic aberration
This commit is contained in:
parent
7d755427e3
commit
17beaf8aa9
|
@ -144,6 +144,10 @@ u_compute_distortion_vive(struct u_vive_values *values, float u, float v, struct
|
|||
float r2 = m_vec2_dot(texCoord, texCoord);
|
||||
float d_inv =
|
||||
((r2 * val.coefficients[i][2] + val.coefficients[i][1]) * r2 + val.coefficients[i][0]) * r2 + 1.0;
|
||||
|
||||
// The scaled part of DISTORT_DPOLY3_SCALED, seems to improve chromatic abberation.
|
||||
d_inv -= val.coefficients[i][3];
|
||||
|
||||
float d = 1.0 / d_inv;
|
||||
|
||||
struct xrt_vec2 offset = {0.5, 0.5};
|
||||
|
|
|
@ -75,8 +75,8 @@ struct u_vive_values
|
|||
//! r/g/b
|
||||
struct xrt_vec2 center[3];
|
||||
|
||||
//! r/g/b, a/b/c
|
||||
float coefficients[3][3];
|
||||
//! r/g/b, a/b/c/d
|
||||
float coefficients[3][4];
|
||||
};
|
||||
|
||||
/*!
|
||||
|
|
|
@ -634,32 +634,38 @@ oh_device_create(ohmd_context *ctx, ohmd_device *dev, const char *prod)
|
|||
ohd->distortion.vive[0].coefficients[0][0] = -0.188236068524731f;
|
||||
ohd->distortion.vive[0].coefficients[0][1] = -0.221086205321053f;
|
||||
ohd->distortion.vive[0].coefficients[0][2] = -0.2537849057915209f;
|
||||
ohd->distortion.vive[0].coefficients[0][3] = 0.0f;
|
||||
|
||||
// blue
|
||||
ohd->distortion.vive[0].coefficients[1][0] = -0.07316590815739493f;
|
||||
ohd->distortion.vive[0].coefficients[1][1] = -0.02332400789561968f;
|
||||
ohd->distortion.vive[0].coefficients[1][2] = 0.02469959434698275f;
|
||||
ohd->distortion.vive[0].coefficients[1][3] = 0.0f;
|
||||
|
||||
// red
|
||||
ohd->distortion.vive[0].coefficients[2][0] = -0.02223805567703767f;
|
||||
ohd->distortion.vive[0].coefficients[2][1] = -0.04931309279533211f;
|
||||
ohd->distortion.vive[0].coefficients[2][2] = -0.07862881939243466f;
|
||||
ohd->distortion.vive[0].coefficients[2][3] = 0.0f;
|
||||
|
||||
// right
|
||||
// green
|
||||
ohd->distortion.vive[1].coefficients[0][0] = -0.1906209981894497f;
|
||||
ohd->distortion.vive[1].coefficients[0][1] = -0.2248896677207884f;
|
||||
ohd->distortion.vive[1].coefficients[0][2] = -0.2721364516782803f;
|
||||
ohd->distortion.vive[1].coefficients[0][3] = 0.0f;
|
||||
|
||||
// blue
|
||||
ohd->distortion.vive[1].coefficients[1][0] = -0.07346071902951497f;
|
||||
ohd->distortion.vive[1].coefficients[1][1] = -0.02189527566250131f;
|
||||
ohd->distortion.vive[1].coefficients[1][2] = 0.0581378652359256f;
|
||||
ohd->distortion.vive[1].coefficients[1][3] = 0.0f;
|
||||
|
||||
// red
|
||||
ohd->distortion.vive[1].coefficients[2][0] = -0.01755850332081247f;
|
||||
ohd->distortion.vive[1].coefficients[2][1] = -0.04517245633373419f;
|
||||
ohd->distortion.vive[1].coefficients[2][2] = -0.0928909347763f;
|
||||
ohd->distortion.vive[1].coefficients[2][3] = 0.0f;
|
||||
// clang-format on
|
||||
|
||||
ohd->base.compute_distortion = compute_distortion_vive;
|
||||
|
|
|
@ -895,16 +895,15 @@ _json_get_int(const cJSON *json, const char *name)
|
|||
static void
|
||||
_get_color_coeffs(struct u_vive_values *values, const cJSON *coeffs, uint8_t eye, uint8_t channel)
|
||||
{
|
||||
// this is 4 on index, all values populated
|
||||
// assert(coeffs->length == 8);
|
||||
// only 3 coeffs contain values
|
||||
// For Vive this is 8 with only 3 populated.
|
||||
// For Index this is 4 with all values populated.
|
||||
const cJSON *item = NULL;
|
||||
size_t i = 0;
|
||||
cJSON_ArrayForEach(item, coeffs)
|
||||
{
|
||||
values->coefficients[channel][i] = (float)item->valuedouble;
|
||||
++i;
|
||||
if (i == 3) {
|
||||
if (i == 4) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,16 +30,15 @@
|
|||
static void
|
||||
_get_color_coeffs(struct u_vive_values *values, const cJSON *coeffs, uint8_t eye, uint8_t channel)
|
||||
{
|
||||
// this is 4 on index, all values populated
|
||||
// assert(coeffs->length == 8);
|
||||
// only 3 coeffs contain values
|
||||
// For Vive this is 8 with only 3 populated.
|
||||
// For Index this is 4 with all values populated.
|
||||
const cJSON *item = NULL;
|
||||
size_t i = 0;
|
||||
cJSON_ArrayForEach(item, coeffs)
|
||||
{
|
||||
values->coefficients[channel][i] = (float)item->valuedouble;
|
||||
++i;
|
||||
if (i == 3) {
|
||||
if (i == 4) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue