Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-100138

Camera animation frozen when using QQuickRenderControl

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • 6.4.0
    • 6.2.2
    • Qt RHI, Quick: 3D
    • None
    • macOS 11.6.2, Windows, probably anything

    Description

      I'm using QQuickRenderControl to render QML offscreen. I'm using private Rhi APIs as recommended in QTBUG-88876. I am animating the camera position. This works fine until I introduce a 2D element inside a Node as described in https://doc.qt.io/qt-6/qtquick3d-2d.html

      Once a Node with a 2D Rectangle is introduced, the camera animation stops working.

      I have code to reproduce this at https://github.com/rectalogic/rendercontrol3d

      https://github.com/rectalogic/rendercontrol3d/blob/master/main.cpp is nearly verbatim lifted from tst_RenderControl::renderAndReadBackWithRhi() in qtdeclarative/tests/auto/quick/qquickrendercontrol/tst_qquickrendercontrol.cpp - except it dumps the rendered image to a PNG every 25 frames.

      After building the sample, run build/rc3dtest <qml-file> to dump the PNG snapshots.

      https://github.com/rectalogic/rendercontrol3d/blob/master/rect3d-camera-2d.qml animates the camera Z position. The View3D contains a Node with a 2D Rectangle.

      Run with build/rc3dtest rect3d-camera-2d.qml

      In the image snapshots you can see the camera does not move at all. The camera Z position is shown in a toplevel Text field and also in a Text inside a Node. The Z position shown in the Node is at each snapshot is 500-496-496-496-496,  it does not change after the second dump. The same Z position in the top level Text correctly changes from 500-400-300-200-104. See attached screenshots.

       

      If you simply remove the Node/Rectangle inside the View3D, then everything works - the camera animates. Run build/rc3dtest rect3d-camera-no2d.qml to see this.

       

      Finally build/rc3dtest rect3d-cube-2d.qml animates the cube itself, not the camera. Even though it also contains a Node/Rectangle, it works fine.

       

      So there seems to be some strange interaction when using QQuickRenderControl and animating the camera while the View3D scene contains a 2D Rectangle inside a Node. The other variations described above all seem to work fine.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            janichol Andy Nichols
            rectalogic Andrew Wason
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes