Search code examples
qtqmlqt5.5qt3d

What is ForwardRenderer in Qt 5.5's Qt3D examples?


Assimp example of Qt3d of Qt 5.5 uses ForwardRenderer.

I copied the code, and in main.qml QtCreator shows red line under that name indicating unknown component. Clicking on that word does not take me anywhere.

The program is compiling without any errors, and shows only a blue window when run.

What is ForwardRenderer? Why is the red line there?

enter image description here


Solution

  • Here are forward renderer files on Qt site:

    https://doc.qt.io/archives/qt-5.6/qt3d-dynamicscene-cpp-forwardrenderer-H.html

    https://doc.qt.io/archives/qt-5.6/qt3d-dynamicscene-cpp-forwardrenderer-cpp.html

    Here is the explanation from KDAB what is FrameGraph and how it deals with Forward Renderer: http://www.kdab.com/qt3d-2-0-framegraph/

    ForwardRenderer is not a FrameGraph Node type in itself. It is a default FrameGraph tree implementation for a forward renderer provided as a convenience for users.

    Update: Recreate it manually

    By inspecting the C++ I was able to recreate ForwardRenderer entirely in QML

        // FwdRenderer.qml
        RenderSettings {
            id: forward
            property Camera camera: null
            activeFrameGraph: TechniqueFilter {
                matchAll: [ FilterKey { name: "renderingStyle"; value: "forward" } ]
                RenderSurfaceSelector{
                    Viewport {
                        normalizedRect: Qt.rect(0,0,1,1)
                        CameraSelector{
                            camera: forward.camera
                            ClearBuffers{
                                buffers: ClearBuffers.ColorDepthBuffer
                                clearColor: Qt.rgba(1.0,0,0,0.1)
                            }
                            FrustumCulling{
                            }
                        }
                    }
                }
            }
        }
    

    This was in fact, kind of cool. The new type FwdRenderer can act as a drop-in replacement of ForwardRenderer. It helped me a lot in understanding the Framegraph, hope it helps.

    And by the way, the red line is a bug in that version of Qt Creator. It shouldn't be marked as an error.