Qt Quick 3D - Principled Material Example

Demonstrates the use of Principled Material.

This example demonstrates two different ways to use PrincipledMaterial in an application.

Setting Up the Scene

Light Probe

We specify a light probe, since we are using reflective metallic materials in the scene. We need to enable the light probe and adjust its settings to get the result we want.

environment: SceneEnvironment {
    clearColor: window.color
    backgroundMode: SceneEnvironment.SkyBox
    lightProbe: Texture {
        source: "maps/OpenfootageNET_garage-1024.hdr"
    }
    probeOrientation: Qt.vector3d(0, -90, 0)
}
Rotating Light

Then we add DirectionalLight and add a rotation for it, to better demonstrate the effect that the metalness and roughness properties have on the materials.

// Rotate the light direction
DirectionalLight {
    eulerRotation.y: -100
    brightness: 1
    SequentialAnimation on eulerRotation.y {
        loops: Animation.Infinite
        PropertyAnimation {
            duration: 5000
            to: 360
            from: 0
        }
    }
}

Principled Materials

Basic

We apply a basic principled material onto the sphere on the left. By this we mean a material that only uses the basic, numeric properties without any texture properties.

Model {
    position: Qt.vector3d(-250, -30, 0)
    scale: Qt.vector3d(4, 4, 4)
    source: "#Sphere"
    materials: [ PrincipledMaterial {
            baseColor: "#41cd52"
            metalness: materialCtrl.metalness
            roughness: materialCtrl.roughness
            specularAmount: materialCtrl.specular
            specularTint: materialCtrl.specularTint
            opacity: materialCtrl.opacityValue
        }
    ]
}
Textured

We apply a textured principled material onto the sphere on the right.

Note: When using textures for metalness, roughness, bumpiness, and color, the basic property values are applied as multipliers for the values from the textures.

Model {
    position: Qt.vector3d(250, -30, 0)
    scale: Qt.vector3d(4, 4, 4)
    source: "#Sphere"
    materials: [ PrincipledMaterial {
            metalness: materialCtrl.metalness
            roughness: materialCtrl.roughness
            specularAmount: materialCtrl.specular
            opacity: materialCtrl.opacityValue

            baseColorMap: Texture { source: "maps/metallic/basecolor.jpg" }
            metalnessMap: Texture { source: "maps/metallic/metallic.jpg" }
            roughnessMap: Texture { source: "maps/metallic/roughness.jpg" }
            normalMap: Texture { source: "maps/metallic/normal.jpg" }

            metalnessChannel: Material.R
            roughnessChannel: Material.R
        }
    ]

Controlling the Property Values

There are sliders for adjusting the values of the different basic properties.

Note: If Metalness has a non-zero value, adjusting Specular Power or Specular Tint has no effect.

Files:

Images:

© 2024 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.