Home

Awesome

Quartz

© 2018 - 2019 Michał Siejak (@Nadrin)

A physically based GPU path tracing renderer with a declarative scene description language based on ES7.

Powered by Qt 3D, NVIDIA RTX & Vulkan.

Images rendered by Quartz

Current release

Overview

Quartz consists of several components:

Features

This project is still a work in progress. Items without a check mark are planned but not yet implemented at this time.

System requirements

Quartz requires a NVIDIA GPU with support for the following Vulkan extensions:

Usage

To use the standalone renderer run Quartz.exe (or ./quartz, on Linux) and select a QML scene file in the open file dialog. Alternatively you can use the command line:

Quartz.exe [-x <viewport_width>] [-y <viewport_height>] [path_to_qml_file]

If the opened QML file contains an instance of FirstPersonCameraController the camera can be controlled interactively. Press and hold either left or right mouse button and drag the mouse around to rotate the view. Use the usual W, S, A, and D for movement. Q and E move up and down respectively.

Press F2 to save an output image file. Saving to HDR (Radiance) format writes a raw floating-point image in linear space. Saving to any other format writes a tone-mapped, gamma corrected image.

QML scene description language

QML is a declarative language based on ES7, used by Qt 3D (and thus Quartz) to describe scene hierarchy and all required resources like textures and triangle meshes.

Each QML file consists of a root Entity and any number of child nodes, which themselves can also contain child nodes (thus forming a DAG). In most cases a Node is either an Entity or a Component. Entities can contain a number of components (but no more than one component of each type). Examples of components include: Transform, Material, and Mesh.

Every node type exposes some number of properties. A property can be bound to a simple value like 42, a node instance, or to an arbitrary JavaScript expression. The id property is special and uniquely identifies an instance of a node.

Qt 3D & QML documentation:

"Hello, World" in Quartz QML

Proper documentation of Quartz QML types is still in the oven. In the meantime here's a simple QML scene to serve as an example:

import QtQuick 2.0
import Qt3D.Core 2.0
import Qt3D.Raytrace 1.0

Entity {
    id: root
    components: [
        RenderSettings {
            camera: camera
            skyColor: "#00C5FF"
            skyIntensity: 1
        }
    ]
    Camera {
        id: camera
        position: Qt.vector3d(0, 0, 2.6)
        exposure: 1.0
        fieldOfView: 60
    }
    Entity {
        Transform {
            id: sunTransform
            rotationX: 60
            rotationY: -15
            rotationZ: 35
        }
        DistantLight {
            id: sunLight
            color: Qt3DRaytrace.lrgba(1.0, 0.9, 0.8)
            intensity: 5
        }
        components: [ sunTransform, sunLight ]
    }
    Entity {
        Transform {
            id: monkeyTransform
            translation: Qt.vector3d(-0.1, 0, 0)
            rotationY: -30
        }
        Material {
            id: monkeyMaterial
            albedo: "crimson"
            roughness: 0.5
        }
        Mesh {
            id: monkeyMesh
            source: "monkey.obj"
        }
        components: [ monkeyTransform, monkeyMaterial, monkeyMesh ]
    }
}

Image rendered with the above QML code

Note on colors

Since Qt has no notion of color spaces, all color values are assumed to be in sRGB by default. To specify linear color use the Qt3DRaytrace.lrgba() function.

For symmetry there's also Qt3DRaytrace.srgba() which is equivalent to Qt.rgba().

Loading 3D models

Quartz uses Assimp for importing 3D models and thus supports many common file formats, including: Wavefront (OBJ), Autodesk FBX, Collada (DAE), glTF, and others.

Note that Mesh component treats its source file as if containing a single 3D object. Multiple objects are pre-transformed and joined into one during import.

To work with complex 3D scenes use the scene2qml tool. It converts an input scene file into QML-defined Entity hierarchy and extracts individual meshes, and textures into separate files. The resulting QML file can then be imported by using the EntityLoader node.

Conversion quality depends on the input file format and complexity of a particular scene. The resulting QML file can be further edited by hand to supplement certain information, like some Material attributes.

Building

Prerequisites

Environment setup

VariableDescriptionExample value
QTDIRPath to Qt 5.12 headers & librariesC:\Qt\5.12.0\msvc2017_64
VULKAN_SDKPath to Khronos Vulkan SDK (Windows only)C:\VulkanSDK\1.1.97.0
ASSIMP_ROOT_DIRPath to Assimp SDK (Windows only)C:\Program Files\Assimp

Steps to build

  1. Compile GLSL shaders to SPIR-V by running: src\raytrace\renderers\vulkan\shaders\compile.py.
  2. Configure & build the project using the top level CMakeLists.txt file.

Note for Linux: Make sure that the version of Qt being used ships with Vulkan support enabled at compile time. Official Qt binaries for Linux support Vulkan since version 5.13.

Running development builds

Before you run anything make sure that QML2_IMPORT_PATH is configured to look for Quartz QML plugin binaries.

On Windows, also make sure that respective directories containing Qt53DRaytrace.dll and Qt53DRaytraceExtras.dll are both in PATH.

Project structure

PathDescription
/3rdpartyThird party libraries
/apps/quartzStandalone renderer application
/apps/scene2qml3D scene to QML conversion tool
/cmakeLocal CMake modules
/docDocumentation (WIP)
/examples/assetsAssets used by example projects
/examples/raytrace-cppC++ API usage example
/examples/raytrace-qmlQML API usage example
/includePublic C++ API include files
/src/extrasExtras library (Qt3DRaytraceExtras)
/src/qmlQML plugins
/src/raytraceRaytracing aspect library (Qt3DRaytrace)
/src/raytrace/renderers/vulkanRaytracing aspect Vulkan renderer

Third party libraries

This project makes use of the following open source libraries: