Author Topic: JPCT + Vuforia in stereo rendering mode  (Read 4177 times)

Offline thejauffre

  • byte
  • *
  • Posts: 14
    • View Profile
JPCT + Vuforia in stereo rendering mode
« on: April 11, 2018, 10:15:19 am »
Hi everybody,
I'm working on a project in which I have to perform stereo rendering (using smartglasses and/or a VR viewer) using Vuforia and JPCT-AE. I am working on the DigitalEyewear example.
I followed the instructions to integrate Vuforia and JPCT in the mono rendering case, as explained in the wiki, and tried to replicate them to the stereo-rendering without success.
This is what I understood: in the mono-rendering, I just had to find the modelview matrix associated to an image target, then update the JPCT camera and start the rendering. I tried the same for the stereo case, taking into account that Vuforia has to simulate the views of the two eyes, using two virtual camera FOVs; this kinda works, but the object is not correctly displaced in the scene (i.e. I expect it to be on the origin, but it is somewhere else).
I tried to solve this problem in several ways (i.e. rotating/rescaling the modelview matrix or multiplying it by a projection matrix) but it doesn't work.
Any ideas? Thanks.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: JPCT + Vuforia in stereo rendering mode
« Reply #1 on: April 11, 2018, 11:13:13 am »
The approach sounds reasonable, I guess. Is the object rotated correctly and "just" the translation is wrong!?

Offline thejauffre

  • byte
  • *
  • Posts: 14
    • View Profile
Re: JPCT + Vuforia in stereo rendering mode
« Reply #2 on: April 11, 2018, 12:13:50 pm »
Well, if I use just the modelview matrix to update the camera, i don't even see the object.
If I rotate the modelview matrix of -90 degrees about x axis, I can see it, in a wrong position/rotation of course (but at least it is visible).

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: JPCT + Vuforia in stereo rendering mode
« Reply #3 on: April 11, 2018, 01:39:28 pm »
...and in "mono"-view, it works?

Offline thejauffre

  • byte
  • *
  • Posts: 14
    • View Profile
Re: JPCT + Vuforia in stereo rendering mode
« Reply #4 on: April 11, 2018, 03:48:56 pm »
Yes, if I use just the modelview matrix without any modification (as in the wiki) the object is displaced correctly.

Offline thejauffre

  • byte
  • *
  • Posts: 14
    • View Profile
Re: JPCT + Vuforia in stereo rendering mode
« Reply #5 on: April 11, 2018, 05:03:06 pm »
Ok, I found the problem: the size of the image target inside the database was not the same as I expected, so I guess it was just a problem of sizing.
Thanks :)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: JPCT + Vuforia in stereo rendering mode
« Reply #6 on: April 16, 2018, 07:35:10 am »
Good to hear that you've solved it.

Offline thejauffre

  • byte
  • *
  • Posts: 14
    • View Profile
Re: JPCT + Vuforia in stereo rendering mode
« Reply #7 on: April 19, 2018, 10:11:02 am »
Hi! i'm sorry to bother, but i still have some problems.
Using just the modelview matrix works fine when the video background is active. In fact, when using the smartglasses in see-through mode, Vuforia applies a projection matrix (retrieved after a per-user calibration process) to correctly display a virtual object on the scene, so that the viewer sees it on the marker, like if it was real.
So, i'm trying to use the same projection matrix on JPCT, and, by forcing it touse the same near and far planes as Vuforia, i am able to see the object right over the marker.
However, the rotations of the object are messed up: it's like I'm seeing it from an arbitrary direction, and (for example) when I rotate the marker clockwise, the object rotates counterclockwise. Maybe it is related to the different reference frame used by OpenGL and JPCT. I tried performing a rotation of the final modelviewprojection matrix (namely the product of modelview and projection mats) about 90 deg about x-axis and a negative scaling on the z-axis, but it has the same problem.
Any ideas?

Offline thejauffre

  • byte
  • *
  • Posts: 14
    • View Profile
Re: JPCT + Vuforia in stereo rendering mode
« Reply #8 on: April 20, 2018, 05:09:22 pm »
Ok, i managed to solve part of the problem by tuning the FOV and near/far plane of JPCT camera (as i read here in the forum, applying Vuforia/OpenGL matrices is not recommended).
Now I can see the object (a square) almost on the marker, but it is stretched: it's like the horizontal side is larger than it should be.
I checked the framebuffer size, tried to change the FOV values and the planes, but nothing changed.
What could be the problem?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: JPCT + Vuforia in stereo rendering mode
« Reply #9 on: April 23, 2018, 07:53:57 am »
Do you have a screen shot?

Offline thejauffre

  • byte
  • *
  • Posts: 14
    • View Profile
Re: JPCT + Vuforia in stereo rendering mode
« Reply #10 on: April 23, 2018, 09:52:28 am »
Sure.
In the archive there are two screenshots (their names are self-explanatory).
I got the "correct" one by scaling the modelview matrix along the x direction, but this is like cheating (in fact, if I rotate the marker, the object will be stretched)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: JPCT + Vuforia in stereo rendering mode
« Reply #11 on: April 23, 2018, 10:35:53 am »
If you've played around with the fov settings...have you just changed fov or yfov as well?

Offline thejauffre

  • byte
  • *
  • Posts: 14
    • View Profile
Re: JPCT + Vuforia in stereo rendering mode
« Reply #12 on: April 23, 2018, 11:19:37 am »
I changed both. X and Y FOV are set to PI/8.5 and PI/17 respectively. However, I'm noticing that changing them does not affect the rendering - which is strange. Maybe I messed up with something, gonna check it.


Edit: Ok, changing the values of the FOVs the rendering is not stretched anymore (i put fov=1, fovY = 0.55). Still, I need to decrease fovx to a smaller value (basing on some calculations, I need it to be around 20 degrees); setting it to values lower than the unit causes the deformation, no matter the value of fovY.

Edit2: "accidentally", i found the setFOVLimits method. Well, now I can set the FOVs as I like :D
« Last Edit: April 23, 2018, 03:30:07 pm by thejauffre »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: JPCT + Vuforia in stereo rendering mode
« Reply #13 on: April 24, 2018, 10:06:30 am »
Yeah, sorry about that method. I should have mentioned it and I really can't remember why I put that in...