[Development] Qt3D questions and wishes

Sean Harmer sean.harmer at kdab.com
Sat Aug 15 16:07:38 CEST 2015


Hi,

sorry for the delay I've been on the road and super busy (and jet lagged).

On 10/08/2015 09:15, Randall O'Reilly wrote:
> Harald — I filed a few bug tickets with example code for some of these issues, as noted below.
>
> - Randy
>
>> On Aug 9, 2015, at 11:35 PM, Harald Vistnes <harald.vistnes at gmail.com> wrote:
>>
>> Hi,
>>
>> I have played with the tech preview of Qt3D 2.0 and I have some questions and wishes.
>>
>> 1. Transparency. It does not seem like Qt3D handles transparency at all. For instance, phong.frag always returns alpha=1.0. I would expect materials like Qt3D::QPhongMaterial to have an opacity parameter and that the renderer would first render opaque meshes and then transparent meshes sorted by depth. Ideally I would love to have support for OIT out of the box, but that may be too specialized. Will there be any support for transparent materials in the upcoming release?
> This requires extra transparency-specific shader code and alpha blending logic, so that is presumably why it is not supported by default.  But hopefully the next release will include these kinds of transparency cases:
>
> https://bugreports.qt.io/browse/QTBUG-47445
> https://bugreports.qt.io/browse/QTBUG-47446

Paul has now added a phong material with transparency support. We still 
need to add another default framegraph to allow an alpha blended pass to 
be used easily out of the box but that should be trivial.

>
>> 2. Shared vertex buffers. How can multiple meshes share the same vertex buffer?

We've just added a new Buffer/Attribute API that is more flexible than 
what was there before. The functor approach is still possible (it is now 
used to either populate buffers only or a complete GeometryRenderer 
object). It also supports instancing and instanced arrays (once a couple 
more patches get merged). Primitive restart is also supported out of the 
box now too.

I'm also looking into using javascript typed arrays to provide the 
VBO/IBO data.

>>
>> 3. Updating vertex buffers. How can one update the vertices of an existing mesh? Qt3D::QAbstractMesh only expose the meshFunctor() function, so I don't see how to update an existing mesh with new vertex data.
> there is an update() method on the abstract mesh, which sends a property update signal for the mesh functor or something like that.
>
>> 4. Text. It would be nice with an example showing how to add text to a Qt3D scene. Both 2D (specified in screen coordinates) and 3D (specified in world coordinates). I'm only using C++, so that is what is of interest to me.
> https://bugreports.qt.io/browse/QTBUG-19234
>
> This is probably not super efficient but it does work: renders text to a QImage and uses that for a texture.  Using the transparent version of the texture you just get the 2D text floating in space.  Uses 3D coordinates, but renders text to a plane.

Yes we're aware this is needed. Unlikely to land in 5.6 but we will try 
to add an example showing how to do it as Randy described and then put a 
more complete solution in for 5.7.

>
>> 5. It would be nice to have a class like QTriangleMesh out of the box where the user can specify his own vertices, normals, indices, etc. I implemented such a class following the pattern of the Qt3D::QCylinderMesh implementation, but ended up with a copy of the vertex/index arrays in both the TriangleMeshPrivate and TriangleMeshFunctor class before they were actually used in the Qt3D::QAbstractMeshFunctor::operator()(). Is there a better way to handle this, to avoid all those copies of the data?

The new buffer/attribute API should support this out of the box now.
> I wrote a TriangleStripSet class that has float vectors for vertices and normals, and for per-vertex colors, and an int vector for indexes — it was fairly straightforward but uses non-Qt dynamic vector classes so not directly sharable.  It also uses the primitive reset index technique so you can easily restart the triangle strips: https://bugreports.qt.io/browse/QTBUG-47291
>
>> 6. Polygon offset to handle z-fighting.

There is already a PolygonOffset state object that can be used in state 
sets in RenderPasses or StateSets in the framegraph. It's up to you to 
use it where needed as we can't possibly guess.

>>
>> 7. All examples in C++. In the tech preview, many of the examples were QML only.

The C++ and QML APIs should be pretty much 1 to 1. Patches welcome if 
you'd like to see more pure C++ examples.

>>   
>>
>> Thanks. I'm looking forward to see the progress in the next release!

Me too :) We've made quite a lot of improvements since 5.5.0 but there's 
much more in the pipeline (excuse the pun) for 5.7 and beyond.

As always, all help welcomed.

Cheers,

Sean

-- 
Dr Sean Harmer | sean.harmer at kdab.com | Managing Director UK
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - Qt Experts - Platform-independent software solutions




More information about the Development mailing list