ValveSoftware / steamworks-vr-api

Source for the Steamworks VR API
Other
137 stars 30 forks source link

eye matrices are reversed (or in camera space), improperly combined with the orientation. #9

Open jherico opened 10 years ago

jherico commented 10 years ago

Fetching the eye matrix for the left eye produces a negative value for the X translation. This implies that the eye matrix is in camera space, and needs to be inverted if it's to be applied to the view matrix. However, in CHmdLatest::GetViewMatrix() the eye matrix is pre-multipled with the head orientation / position matrix without being inverted.

The orientation is in view space, so once the translation and rotation have been combined there's no way to correct the matrix except by swapping left and right.

The problem is most easily seen if you render a very small color cube at a short distance from the camera so that parallax effects are very obvious.

Looking left, the cube moves to the right, but the cyan colored left side of the cube comes into view on the right eye, rather than the left eye, which should have a better angle on the left surface.

image

Turning the headset to the right shows the opposite effect:
image

Attempting to center the cube shows that the two views of the object are each translated slightly outward from the lens axis points image

Because the raw left eye and right eye matrices are each the inverse of the other, you can correct this by swapping them, or by swapping the left and right results from CHmdLatest::GetViewMatrix()

The example code used to generate these images is available here: https://github.com/jherico/OculusRiftInAction/blob/0b99d3f38e2cce8eb303469ec4a30f494397805a/source/steamworks/Example_Steamworks.cpp