Demonstrates the use of the Kuesa API to import a glTF2 file and control its appearance by using different tone mapping algorithms.
The tonemapping example relies on the regular QtQuick and Qt 3D APIs to instantiate a QtQuick based application that combines Qt 3D based content with a 2D UI overlay.
Item { id: root Item { id: baseUI anchors.fill: parent Scene3D { id: scene3d anchors.fill: parent focus: true multisample: true aspects: ["render", "input", "logic", "animation"] MainScene { id: sceneEntity screenWidth: scene3d.width screenHeight: scene3d.height exposure: menu.exposure rotating: menu.toggleRotation lightRotating: menu.toggleLightRotation toneMappingAlgorithmName: menu.toneMappingAlgorithmName } } } ...
Kuesa provides the SceneEntity element which holds collections of Qt 3D assets accessible by name.
import Qt3D.Core 2.12 import Qt3D.Render 2.12 import Qt3D.Input 2.12 import Qt3D.Extras 2.12 import QtQuick 2.12 import Kuesa 1.1 as Kuesa import Kuesa.Effects 1.1 as KuesaFX import Kuesa.Utils 1.3 as KuesaUtils Kuesa.SceneEntity { id: root3D property string toneMappingAlgorithmName: "None" ...
In order to load a glTF2 file, Kuesa provides the GLTF2Importer element. If the sceneEntity property is set to a valid SceneEntity instance, Qt 3D assets generated while parsing the file will be automatically added to the various asset collections.
Kuesa.GLTF2Importer { id: gltf2importer sceneEntity: root3D assignNames: true source: "qrc:/RotatingHelmet.gltf" options.generateTangents: true }
We use a ForwardRenderer FrameGraph to render our scene. This FrameGraph has properties to control the exposure as well as the tone mapping algorithm we want to use.
Therefore we can create a binding on the toneMappingAlgorithm property of our ForwardRenderer FrameGraph to control the tonemapping algorithm used
activeFrameGraph: Kuesa.ForwardRenderer { id: frameGraph camera: cameraAsset.node ? cameraAsset.node : fallbackCamera clearColor: Qt.rgba(0.1, 0.1, 0.1, 1.0) exposure: root3D.exposure toneMappingAlgorithm: { if (toneMappingAlgorithmName == "Filmic") return KuesaFX.ToneMappingAndGammaCorrectionEffect.Filmic if (toneMappingAlgorithmName == "Reinhard") return KuesaFX.ToneMappingAndGammaCorrectionEffect.Reinhard if (toneMappingAlgorithmName == "Uncharted") return KuesaFX.ToneMappingAndGammaCorrectionEffect.Uncharted return KuesaFX.ToneMappingAndGammaCorrectionEffect.None } skinning: true }
Files:
Images: