Presentation is loading. Please wait.

Presentation is loading. Please wait.

3D programming in Delphi

Similar presentations


Presentation on theme: "3D programming in Delphi"— Presentation transcript:

1 3D programming in Delphi
Introduction to 3D programming in Delphi

2 ykot@afterwarp.io http://afterwarp.io Yuriy Kotsarenko R&D Consulting
Developer of Asphyre / Platform eXtended Library:

3 Agenda Why 3D? The basics of 3D programming
Using Direct3D and OpenGL directly Using FireMonkey Other libraries Advanced 3D concepts The future

4 Natural spatial representation
So why going 3D? Natural spatial representation Model industrial processes accurately Visualize and manipulate real world data Visual realism Easier to interpret for human eye Professionally looking GPGPU Harness the power of GPU for general-purpose work!

5 The basics of 3D programming
3D vectors: X, Y and Z 3D matrices (4x4 array) Translation Rotation Scaling A combination of above… 3D vector multiplied by matrix Applying transformation 3D matrix multiplied by another matrix Combining multiple transformations Order is important!

6 The basics of 3D programming
World matrix Place object in 3D world. Scale, move, rotate, etc. View matrix How do we see the world? Eye position, direction and orientation. Projection matrix How the world is displayed. Field of view, aspect ratio, dimensions…

7 The basics of 3D programming
V(2) Indices Vertices I(0) = 2 I(1) = 0 I(2) = 1 V(1) V(0)

8 “Write games, not engines” Prefer framework rather than an engine
3D: What library to use? “Write games, not engines” Prefer framework rather than an engine Remember KISS and YAGNI principles! Avoid unnecessary complexity Avoid unnecessary features Too many options to choose from are not necessarily a good thing. Choose none! :)

9 Using Direct3D in Delphi
Direct3D is a de-facto Windows standard! Excellent driver and hardware support. Good documentation on MSDN web site. Delphi Tokyo 10.2 comes with latest DirectX headers. Delphi RTL provides all necessary 3D vector types and functions. Tutorial application on GitHub:

10 Using Direct3D in Delphi
Application Window D3D Swap Chain D3D Device D3D Context DXGI Factory D3D Shaders D3D Buffers D3D Views

11 Using Direct3D Directly
Let’s open Direct3DTutorial project!

12 Using OpenGL in Delphi Ne-He Tutorials: Delphi OpenGL community:
Delphi OpenGL community: (site in German) Embarcadero blogs: Many others (several pages on Google)

13 Let’s see some existing examples!
Using OpenGL Directly Let’s see some existing examples!

14 OpenGL: what to watch for
Mixing Legacy (GL2) and Core (GL3+) features Many online examples have legacy or hybrid code. Difficult to know if certain function, enumeration or a specific value is deprecated or not. Hard to predict efficient code-path. Limited support on OS X (only 4.1 out of 4.6) No Compute Shaders :( Windows drivers issues Nvidia (excellent), AMD (good) and Intel (mediocre).

15 OpenGL: considerations
Fun learning experience Large community and collection of online materials. Get things done in few lines of code Legacy features? Use them! :) Currently all vendors support them fully and well. Beginner friendly: code is very short and elegant. Try things before getting into “serious stuff”. Avoid using in a production environment Instead focus on Vulkan, Metal and/or Direct3D APIs.

16 Let’s try some basic example!
Using FireMonkey Let’s try some basic example!

17 Using FireMonkey FireMonkey 3D design characteristics
Wrapping Direct3D and OpenGL APIs DirectX on Windows, OpenGL on others Mixed fixed-function and programmable concepts Oriented towards UI applications Basic 3D functionality Simple shapes and models Minimalistic lighting without shadows Shader effects baked on top Might be difficult to use latest GPU features

18 FireMonkey 3D strengths
Strong 3D math and vector framework in RTL Initially was part of FireMonkey, now resides in System.Math.Vectors.pas GUI-oriented, facilitates showing UI on 3D surfaces See ControlsDemo (ControlsDesktop) example. Hardware-Accelerated Direct3D 11 Canvas with Batching GlobalUseGPUCanvas := True

19 Other libraries GLScene Supports many different 3D graphics formats.
Great integration with third-party physics, scripting and game engines. Many service and helper functions: Cadencer, Skyboxes, Perlin noise… Getting outdated (pre-GL2 design?) But seems to have some recent movements! MPL, OpenGL-only :( Installation issues in Delphi Tokyo

20 Other libraries Castle Game Engine
A great collection of features – shadows, bump mapping, mirrors, etc. Supports a large variety of 2D and 3D formats. Integrated with Kraft Physics Engine. Interesting features such as sound and editors. (L)GPL, OpenGL-only :(

21 Other libraries Other “game engines” out there
Proprietary vs open-source C/C++ libraries and engines Unity Unreal Ogre3D Afterwarp Framework ( We’ll see a quick preview shortly… But we’ll talk more about this one tomorrow. :)

22 Advanced 3D Real-time Shadows Order-Independent Transparency
Shadow Volumes Shadow Maps Hard edges Soft edges Order-Independent Transparency Instancing Generating Geometry directly on GPU

23 The Future Compute Shaders and GPGPU Ray-tracing
More powerful AI Physics Parallel computing Ray-tracing Nvidia Opti-X Ray Tracing Engine Direct3D 12 Ray Tracing API Where we go from here?


Download ppt "3D programming in Delphi"

Similar presentations


Ads by Google