Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
philigaultier's avatar
philigaultier
Honored Guest
12 years ago

Oculus Rendering seems off, what is wrong?

Hi,

I've written a sample application with SDKL, OpenGL and SDK 0.3.2 (https://github.com/gaultier/SDL2_OpenGL3.3_Sample). Simple scene, just a cube on a plane and a texture in the background.

My rendering seems weird though (see file attached).

When I put the Oculus on, both images don't quite match up.
Someone told me I might be rendering the eyes inverted (ie right eye on left eye part and vice versa).

Can you tell me what's wrong?

Here's my rendering loop (simplified):


void Oculus::render(Scene * scene)
{
scene_ = scene;

computeSizes();
setCfg();

ovrBool configurationRes = ovrHmd_ConfigureRendering(hmd_, &cfg_.Config, distortionCaps_, eyeFov_, eyeRenderDesc_);
//Cannot configure OVR rendering
assert(configurationRes);

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glUseProgram(0);


setEyeTexture();

frameTiming_ = ovrHmd_BeginFrame(hmd_, 0);

// Bind the FBO...
glBindFramebuffer(GL_FRAMEBUFFER, FBOId_);
// Clear...
glClearColor(1, 1, 1, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

for (int eyeIndex =0; eyeIndex < ovrEye_Count ; eyeIndex++)
{
ovrEyeType eye = hmdDesc_.EyeRenderOrder[eyeIndex];
ovrPosef eyePose = ovrHmd_BeginEyeRender(hmd_, eye);

glViewport(eyeTexture_[eye].OGL.Header.RenderViewport.Pos.x,
eyeTexture_[eye].OGL.Header.RenderViewport.Pos.y,
eyeTexture_[eye].OGL.Header.RenderViewport.Size.w,
eyeTexture_[eye].OGL.Header.RenderViewport.Size.h
);

// Get Projection and ModelView matrici from the device...
OVR::Matrix4f projection = ovrMatrix4f_Projection(eyeRenderDesc_[eye].Fov, 0.3f, 100.0f, false);
OVR::Quatf orientation = OVR::Quatf(eyePose.Orientation);
OVR::Matrix4f modelView = OVR::Matrix4f(orientation.Inverted());

// Pass matrici on to OpenGL...
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMultMatrixf(&(projection.Transposed().M[0][0]));
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// Translate for specific eye based on IPD...
glTranslatef(eyeRenderDesc_[eye].ViewAdjust.x,
eyeRenderDesc_[eye].ViewAdjust.y,
eyeRenderDesc_[eye].ViewAdjust.z);
// Multiply with orientation retrieved from sensor...
glMultMatrixf(&(modelView.Transposed().M[0][0]));

scene_->render();


ovrHmd_EndEyeRender(hmd_, eye, eyePose, &eyeTexture_[eye].Texture);
}

ovrHmd_EndFrame(hmd_);
}


I'm sure the mistake is obvious but I don't see it.

Thanks for your help.

2 Replies

  • Yeah, your eyes are backwards. Look at the screenshot you posted of the Rift output. The left view should be the left eye, so your viewpoint should be on the left side of the box. Depending on the size of the area you're rendering, the camera separation seems awfully high, the difference between views shouldn't be that drastic.. it's like your eyes are five or six feet apart instead of standard IPD.