introducing qt3d 2.0: a qt framework for 3d …...history qt3d originally developed by the brisbane...

26
Introducing Qt3D 2.0: a Qt framework for 3D rendering and visualisation James Turner KDAB

Upload: others

Post on 20-Mar-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

Introducing Qt3D 2.0: a Qt framework for 3D rendering and visualisationJames Turner

KDAB

Page 2: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

Agenda

● Introduction● History● Goals

● Simple QML example● Advanced QML example

● Entity component model● Simple C++ example● Framegraph configuration● Conclusions

Page 3: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

History

● Qt3D originally developed by the Brisbane office● Various previews / “labs” status in Qt 4 history● First major release: 1.0 (targeting Qt 4.8.1, but not bundled with it)

● Unfortunately, also last release● Not part of any Qt 5 releases

Page 4: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

Qt3D 1.0

● C++ and QML APIs● To define geometry (simple shapes, meshes)● To define geometry materials (Phong + texture)● To define the scene properties (camera, lights, picking)

Page 5: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

Qt3D 1.0 Problems

● Very simple render engine● Solid colours, Phong lighting, simple front/back texturing, EOF● Rendering not configurable: simple forward GL2 / ES2 renderer

● Little to no extensibility of the scene in non-graphical aspects● Physics, audio, …

● Slow!● Non batched rendering● Does not scale

● Development stopped when Nokia ditched Qt

Page 6: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

Qt3D 2.0

● In late 2013 KDAB took over Qt3D development● Complete new design

● Data driven renderer● Entity/Component design, as found in several modern 3D engines

Page 7: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

Goals

● C++ and QML APIs for everything● Extensible

● User-defined render techniques● Not just 3D geometry

● Constraint solving systems, physics, audio, …● Efficient

● Heavily threaded● Tries to batch as much as possible

● Offer alternatives to VTK and similar visualization solutions

Page 8: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

Non goals

● Invent Yet Another 3D Simulation Engine● Not the same scope● Lack of manpower

● Force everyone to use the same rendering techniques● By providing a subset of what we deem “useful”, and ignoring all the other interesting use cases

● Duplicate technologies already in Qt● mainly OpenGL-wrapping APIs

Page 9: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

Simple QML example

● Scene defined entirely in QML● Framegraph defined entirely in QML● Simple animations (“for free”)

Page 10: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

Entity Component System

● Each element of a scene is an node (QObject subclass)● The entire scene is a tree of nodes

● Certain nodes are entities● Any entity is composed by 0 or more components

● Mesh● Transformation● Audio source● …

● F.i.: a 3D shape is an entity with a mesh component (and a transformation)● Totally extensible system

Page 11: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

Entity Component System

Page 12: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

Entity Component System

● Traditional problem: have a class and want to extend it with extra logic● E.g. a class for 3D shapes, and we want to add audio to it

● Traditional solution:● Introduce a base class for audio emitters● Refactor the class into a “Base3DShape” (or maybe “Base3DObject”)● Multiple inheritance● Rinse and repeat for any combination of logic (physics, AI, ...)

Page 13: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

Entity Component System

● Traditional problem: have a class and want to extend it with extra logic● E.g. a class for 3D shapes, and we want to add audio to it

● Component-based solution:● Add a audio emitter component to the entity● ???● Profit!

Page 14: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

Entity Component System

Page 15: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

Aspects

● Aspects walk through the scene and pick up interesting information about entities

● ... attached as components● Examples:

● Rendering aspect (looks for meshes, transformations, materials, etc.)● Audio aspect (looks for audio emitters, listeners, transformations, etc.)● Physics aspect● ...

● A threaded job system triggers when the components change and aspects need to update their status

● More details in the following talk

Page 16: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

Aspects

Page 17: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

More advanced QML example

● Load some mesh files● Qt3D 2.0 can use assimp for loading meshes, scenes, etc. in a variety of formats

● Use multiple render passes● Render to an offscreen surface

Page 18: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

Framegraph configuration

● The way the Qt3D renderer works is totally configurable● Allows custom-defined rendering techniques

● Forward● Wireframe● Deferred● … your imagination/requirements

● Some standard techniques available out of the box

Page 19: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

Framegraph configuration

● Framegraph configuration is not hardwired in C++● Unlike QtQuick's scene graph, which is OK for QtQuick but not flexible for arbitrary 3D

● The configuration is expressed within the scene by adding a framegraph node● Data-driven

● Described by a C++ or QML tree of nodes

Page 20: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

Framegraph configuration

● Material / Effect / Technique classes to define● How a mesh looks like● How to get the wanted effect depending on the framegraph configuration and GPU capabilities

● The framegraph will pick a set of suitable techniques to render the geometry● i.e. the Techniques matching the criteria configured in the framegraph

Page 21: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

Framegraph configuration example

● Each path from a leaf to the framegraph root is a possible “configuration”● Selectors, filters used to establish how that configuration works

● Currently switch between configurations is automatic● Soon™, APIs for controlling what configurations are active/inactive

Page 22: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

Basic C++ example

● A C++ API, matching the QML one, is available● Maybe a little too verbose and low level for now● Prefer QML?

Page 23: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

TODOs

● Lots of API polishing ● Picking

● Possibly as an aspect on its own, for different strategies● More builtin aspects

● OpenAL audio, …● Integration with QtQuick2 scenes

● Having a QtQuick2 overlay on top of a Qt3D scene● Having a Qt3D scene rendered into a QtQuick2 item

● Docs and examples!

Page 24: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

Conclusions

● Qt3D 2.0 is a modern engine for visualizing 3D scenes● Rendering entirely customizable via Techniques● Logic of scenes extensible through the Aspects system● Code available in the wip/newapi branch of the qt3d module● Tech preview coming with Qt 5.4

Page 25: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

Questions?

Page 26: Introducing Qt3D 2.0: a Qt framework for 3D …...History Qt3D originally developed by the Brisbane office Various previews / “labs” status in Qt 4 history First major release:

Thank you!

If you're interested in the low-level details of Qt3D 2.0, don't miss the next talk in this room:

Behind the Scenes of Qt3D 2.0