Skip to content

Kuesa Reflection Planes

Kuesa provides support for reflection planes provided in glTF files through a custom glTF extension.

Kuesa 2.0

Kuesa provides support for reflection planes provided in glTF files through a custom glTF extension.

Adding Reflection Planes to a glTF scene

Using Blender

Assuming the Kuesa Studio Blender addon has been installed, the use of Reflection plane is straightforward.

a Reflection Plane

blender_reflection_planes_step1.png

In Blender, reflection planes are found unded the Light Probe section.

Reflections

Once the plane has been positioned and scaled, make sure to select the Rendered Viewport Shading.

blender_reflection_planes_step2.png

Next, go to the Object Data Properties tab of the Reflection Plane and enable the Show Preview Plane checkbox.

blender_reflection_planes_step3.png

Reflection Planes

To export reflection planes, you only need to ensure that the KDAB_kuesa_reflection_planes extension has been selected in the export dialog.

blender_reflection_planes_step4.png

Retrieving Reflection Planes

When loading a glTF file using the qmltype{GLTF2Importer} referencing a SceneEntity all reflection planes found while parsing while be added to the

{Kuesa::Qt3D::ReflectionPlaneCollection} {ReflectionPlaneCollection} of the scene entity.

This then allows retrieving the qmltype{ReflectionPlane} instances by name, either directly from the

{Kuesa::Qt3D::ReflectionPlaneCollection} {ReflectionPlaneCollection} if using C++ or though the use of the

C++

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
Kuesa::Qt3D::SceneEntity *sceneEntity = new Kuesa::Qt3D::SceneEntity();
Kuesa::Qt3D::GLTF2Importer *importer = new Kuesa::Qt3D::GLTF2Importer();

QObject::connect(sceneEntity, Kuesa::Qt3D::SceneEntity::loadingDone, [&] () {
    Kuesa::Qt3D::ReflectionPlane *plane = sceneEntity->reflectionPlane("ReflectionPlane");
    ...
});

importer->setSceneEntity(sceneEntity);
importer->setSource(QUrl("file:///reflections.gltf"));

QML

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
import Kuesa 2.0

Kuesa.SceneEntity {
    id: scene
    ...
    Kuesa.GLTF2Importer {
        id: gltf2importer
        sceneEntity: scene
        source: "file:///reflections.gltf"
    }
    Kuesa.Asset {
        id: sceneReflectionPlane
        collection: scene.reflectionPlanes
        name: "ReflectionPlane"
    }
}

Configuring the Forward Renderer for Reflections

Once retrieved, the Kuesa::Qt3D::ReflectionPlane can be set on either the qmltype[CPP] {Kuesa::Qt3D::ForwardRenderer} {ForwardRenderer} or the

{Kuesa::Qt3D::View} {View} instances defined in the framegraph.

It should then be rendered. Please note however that for more advanced cases, using qmltype{Kuesa::Qt3D::View} {Views} can give you more control on the order in which rendering takes place. For instance, you might want to render the reflections after having rendered a background plane.

C++

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
Kuesa::Qt3D::SceneEntity *sceneEntity = new Kuesa::Qt3D::SceneEntity();
Kuesa::Qt3D::ForwardRenderer *renderer = new Kuesa::Qt3D::ForwardRenderer();
Kuesa::Qt3D::GLTF2Importer *importer = new Kuesa::Qt3D::GLTF2Importer();

QObject::connect(sceneEntity, Kuesa::Qt3D::SceneEntity::loadingDone, [&] () {
    Kuesa::Qt3D::ReflectionPlane *plane = sceneEntity->reflectionPlane("ReflectionPlane");
    renderer->addReflectionPlane(plane);
    ...
});
...

QML

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
import Kuesa 2.0

Kuesa.SceneEntity {
    id: scene
    ...
    components: [
        RenderSettings {
            activeFrameGraph: Kuesa.ForwardRenderer {
                id: frameGraph
                reflectionPlanes: [sceneReflectionPlane.node]
            }
        }
     ]
    ...
    Kuesa.Asset {
        id: sceneReflectionPlane
        collection: scene.reflectionPlanes
        name: "ReflectionPlane"
    }
}

Updated on 2023-07-03 at 11:02:17 +0000