Qt 3D Render Pro Tips
To render even the simplest shapes, Qt 3D needs to perform various operations through several stages. If anything goes wrong at any of these stages you may end up, in the best cases with something different than what you expected, in the worst cases with a black screen.
Qt 3D provides a technique selection mechanism allowing you to provide shaders for various rendering APIs and versions of these APIs.
In order to avoid unnecessary waste of your time, you should make sure that your technique's API filter data is correct for the platform you are targeting.
The order of the draw calls performed by the renderer is not necessarily the same as the order of the entities in the scene.
The renderer tries to optimize calls that are sent to the graphics API. It orders draw calls based on the material/shader being used, the render states that are defined for a given material, their depth, the parameters shared in common between two materials, etc.
If your rendering depends on a specific draw order you should then have a few options:
- Filtering with a Qt3DRender::QLayer component and Qt3DRender::QLayerFilter in the FrameGraph
- RenderPass or Technique filtering using Qt3DRender::QRenderPassFilter or Qt3DRender::QTechniqueFilter in the FrameGraph
Mastering blending with proper arguments and functions is an art in itself. Therefore obtaining the proper visual result is often hit and miss.
Anders Riggelsen's online visualizer may help you find out which arguments and functions work for you.
When rendering a Qt 3D scene through a Qt Quick scene with the Scene3D element you should be aware that you might have to adjust the blending arguments of your render state to obtain a sensible rendering. This is because of the way Qt 3D first renders a scene into an offscreen texture which is then blended in with the rest of the Qt Quick scene.
Given the rather limited of troubleshooting given by Qt 3D in its first versions it sometimes helps to have tools to capture OpenGL draw calls and get more clues about what's happening
These tools allow you to gather traces of all the OpenGL calls being made by a Qt 3D application. Having a look at a generated trace file may help you verify that draw calls are being made, textures correctly uploaded, uniforms set with proper values, ...
There are plans for Qt 3D tooling in later releases.
© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.