1
Support / Blitting in VR display happens on left eye only
« on: November 16, 2016, 08:16:29 pm »
Howdy!
In the frame of a VR app, I split the screen in two halves. Each half renders the scene with a different camera position. I set the Config.viewportOffsetX to 0.0f for the left eye and 1.0f for the right eye.
Everything is working like a charm.
I tried to add a reticle in the center of each half screen by blitting a texture but it appears only on the left part of the screen. I understand that it is the same framebuffer that is rendered twice, but I can't figure out a way to do this (I assume I would have the same issue using an Overlay).
My code in onDrawFrame is:
[...]
//LEFT EYE
scn.update();
fb.clear(back);
//The 2 following rotations of the camera
//are needed to set the JPCT camera as it is in Blender.
cam.rotateAxis(cam.getXAxis(), (float) Math.PI/2);
cam.rotateAxis(cam.getYAxis(), (float) Math.PI/2);
//Position left eye
cam.setPosition(new SimpleVector(0.0f+eyeDistance, 0.0f, 1.3f));
//Rendering in the left viewport
com.threed.jpct.Config.viewportOffsetX = 0.0f;
world.renderScene(fb);
world.draw(fb);
//Left reticle
fb.blit(reticleTex, 0, 0, fb.getWidth()/2, fb.getHeight()/2, 256, 256 ,128, 128, 2, false);
//RIGHT EYE
cam.setPosition(new SimpleVector(0.0f-eyeDistance, 0.0f, 1.3f));
com.threed.jpct.Config.viewportOffsetX = 1.0f;
world.renderScene(fb);
world.draw(fb);
// /!\
// Right reticle
// This one appears cut in half by the limit of the (left drawn) framebuffer
fb.blit(reticleTex, 0, 0, fb.getWidth()/2+290, fb.getHeight()/2, 256, 256 ,64, 64, 2, false);
fb.display();
Does someone could give me any advice on how to do this ? This would make my night
And also, I noticed that the reticle is not well centered. It's a bit off-centered and it surprised me since I used the width and height of the framebuffer divided by two. I saw a deprecated method, getOutputWidth/Height, so maybe for some reasons getWidth/Height might not return the right values. Someone knows where I could have some details about this please ? Thank you!
Fixta.
In the frame of a VR app, I split the screen in two halves. Each half renders the scene with a different camera position. I set the Config.viewportOffsetX to 0.0f for the left eye and 1.0f for the right eye.
Everything is working like a charm.
I tried to add a reticle in the center of each half screen by blitting a texture but it appears only on the left part of the screen. I understand that it is the same framebuffer that is rendered twice, but I can't figure out a way to do this (I assume I would have the same issue using an Overlay).
My code in onDrawFrame is:
[...]
//LEFT EYE
scn.update();
fb.clear(back);
//The 2 following rotations of the camera
//are needed to set the JPCT camera as it is in Blender.
cam.rotateAxis(cam.getXAxis(), (float) Math.PI/2);
cam.rotateAxis(cam.getYAxis(), (float) Math.PI/2);
//Position left eye
cam.setPosition(new SimpleVector(0.0f+eyeDistance, 0.0f, 1.3f));
//Rendering in the left viewport
com.threed.jpct.Config.viewportOffsetX = 0.0f;
world.renderScene(fb);
world.draw(fb);
//Left reticle
fb.blit(reticleTex, 0, 0, fb.getWidth()/2, fb.getHeight()/2, 256, 256 ,128, 128, 2, false);
//RIGHT EYE
cam.setPosition(new SimpleVector(0.0f-eyeDistance, 0.0f, 1.3f));
com.threed.jpct.Config.viewportOffsetX = 1.0f;
world.renderScene(fb);
world.draw(fb);
// /!\
// Right reticle
// This one appears cut in half by the limit of the (left drawn) framebuffer
fb.blit(reticleTex, 0, 0, fb.getWidth()/2+290, fb.getHeight()/2, 256, 256 ,64, 64, 2, false);
fb.display();
Does someone could give me any advice on how to do this ? This would make my night

And also, I noticed that the reticle is not well centered. It's a bit off-centered and it surprised me since I used the width and height of the framebuffer divided by two. I saw a deprecated method, getOutputWidth/Height, so maybe for some reasons getWidth/Height might not return the right values. Someone knows where I could have some details about this please ? Thank you!
Fixta.