[Development] StereoViewport for Qt3D

Fabian Bumberger fbumberger at blackberry.com
Thu Nov 21 09:40:22 CET 2013

>> while working on this, the temporary frame buffer used for picking had a size set to 8x8 pixels(!).

For picking the whole scene is rendered using the pick painter for every performed pick. And afaik, if you swich on picking then a pick is performed for every mouse event (including mouse move events). So I guess having such a small FBO was because of performance and memory reasons. But I also noticed that picking is quite unreliable with that.

From: development-bounces+fbumberger=blackberry.com at qt-project.org [development-bounces+fbumberger=blackberry.com at qt-project.org] on behalf of Svenn-Arne Dragly [s at dragly.com]
Sent: Wednesday, November 20, 2013 8:52 PM
To: Sean Harmer
Cc: development at qt-project.org
Subject: Re: [Development] StereoViewport for Qt3D

On ma. 18. nov. 2013 kl. 15.59 +0100, Sean Harmer wrote:
> On Sunday 17 November 2013 23:11:32 Svenn-Arne Dragly wrote:
>> On Wed 06 Nov 2013 12:54:07 PM CET, Rutledge Shawn wrote:
>>> On 28 Oct 2013, at 10:35 PM, Svenn-Arne Dragly wrote:
>>>> Secondly, I was missing a stereo option for the default QML Viewport
>>>> element, and decided to have a look at the implementation in QGLView to
>>>> see if I could port that to the QML Viewport element. Luckily this was
>>>> quite easy (thanks to Qt3D being well designed) and I have uploaded the
>>>> resulting StereoViewport element to a GitHub repository:
>>>> https://github.com/dragly/stereoviewport
>>>> This should compile with Qt5.1.1 and the latest master branch of Qt3D.
>>> Cool. Are you using it with an Oculus Rift, 3D TV or something else?
>> Both and Oculus Rift and a 3D TV, actually. I have tested the stereo
>> mode where the viewport is split in two thoroughly, with one half of the
>> screen for the left eye and the other for the right. It works quite well
>> and seems to be stable.
>>>> Now, I'm wondering if this feature should be a part of the original
>>>> Viewport element. Should I contribute this into the main Qt3D
>>>> repository? If so, what steps should I take before doing this, apart
>>>> from those listed in the Qt Contributing Guidelines? I'm for instance
>>>> not sure if I might have introduced some bugs or damaged any features of
>>>> the original Viewport element. How should I verify that I haven't
>>>> done so?
>>> I don't know much about that but I'm sure you will get a reply from
>>> someone who does. But it sounds like a good feature to have.
>> I hope so too, but if I don't hear anything I'll just try pushing it to
>> gerrit and see how it goes.
> Apologies, I missed this thread. Yes, please submit the patch to gerrit. We're
> not allowed to accept patches any other way.

No worries - thanks for getting back to me.

I pushed the changes now, hopefully in the right way:

I added you (Sean) as a reviewer. I saw that you had been reviewing
earlier contributions to Qt3D, so I hope that's okay.

Before committing, I realized that I had to update the implementation
of "picking" in the Viewport class to handle the new stereo mode. I've
had some issues with picking earlier, and realized, while working on
this, that the temporary frame buffer used for picking had a size set
to 8x8 pixels(!). This seems way too little to actually work. So I
decided to change this to an implementation that renders to a buffer of
the same size as the current viewport and that uses the same camera,
which is the way it's done in QGLView. This solved the reliability
issue and now works for the new stereo mode. If I in any way did
something bad here, feel free to let me know and I'll try to find a way
to support picking without changing the frame buffer size.

I also needed some classes from the same directory as qglview.cpp,
namely QGLDrawBufferSurface and QGLMaskedSurface. These are private, so
I copied the files into the same directory as viewport.cpp for now, but
perhaps there is a way I could use them without code duplication?

> I don't have any 3D stereoscopic
> devices to try it on yet so I'll have to take your word for that part.

Setting the eyeSeparation property on the camera to something other
than 0.0 and the stereoMode property to Viewport.RightLeft on the
viewport, will let you check that the rendering and picking works even
though you don't have any 3D stereoscopic devices.

There's also the option of crossing your eyes to get the 3D effect, but
that can be a quite uncomfortable for longer periods of time.

Best regards,

Development mailing list
Development at qt-project.org
This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.

More information about the Development mailing list