Skip to content

Commit

Permalink
Fix uninitialized HMD warping coefficient
Browse files Browse the repository at this point in the history
The HMD warping shader uses the cubic warping coefficient, but we weren't
initializing it. This fix ensures it's set to zero in both HMD backends.

It's unsatisfying to force the GPU to perform a calculation using a value that
is known to be zero. We'd squeeze out a few cycles by eliminating the cubic
term from the shader. But it's there in the Oculus code, so we better keep it
here.

Oculus is *really* inconsistent in its handling of distortion coefficients.
The shader reads four, but the library writes three. Meanwhile, the device
itself reports six! The Oculus SDK avoids inconsistency by memsetting the
entire array to 0.

Props @parasti for uncovering this flaw.
  • Loading branch information
rlk committed Apr 6, 2014
1 parent ba00825 commit 64e25ab
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions share/hmd_libovr.cpp
Expand Up @@ -85,6 +85,7 @@ extern "C" void hmd_init()
Info.DistortionK[0] = 1.00f;
Info.DistortionK[1] = 0.22f;
Info.DistortionK[2] = 0.24f;
Info.DistortionK[3] = 0.00f;

Info.ChromaAbCorrection[0] = 0.996f;
Info.ChromaAbCorrection[1] = -0.004f;
Expand Down
2 changes: 1 addition & 1 deletion share/hmd_openhmd.c
Expand Up @@ -80,7 +80,7 @@ void hmd_swap()
static const float center = 0.151976f;
static const float scale = 1.714606f;

static const float barrel_correction[] = { 1.00f, 0.22f, 0.24f };
static const float barrel_correction[] = { 1.00f, 0.22f, 0.24f, 0.00f };
static const float chroma_correction[] = { 0.996f, -0.004f, 1.014f, 0.000f };

hmd_common_swap(center, scale, barrel_correction, chroma_correction);
Expand Down

0 comments on commit 64e25ab

Please sign in to comment.