Improved versions of Ab3d.PowerToys and Ab3d.DXEngine published

by abenedik 28. June 2021 15:48

Another new version of Ab3d.PowerToys and Ab3d.DXEngine libraries have been released.

Though this is a minor release, it still brings some amazing new improvements. For those of you that are rendering complex 3D graphics and also need to show WPF controls on top of the 3D scene, the new version of Ab3d.DXEngine brings two new great features:

1)

The performance of DirectXImage presentation type (required to show WPF controls on top of 3D scene) has been significantly improved. This was done by improving the Ab3d.DXEngine so that it can wait in a background thread until the graphics card finishes rendering the 3D scene. Then Ab3d.DXEngine invokes the code on the main thread that sends the rendered scene to the WPF composition engine. This means that the main thread does not need to wait anymore for the graphics card to complete the rendering of the 3D scene.

The most significant performance improvement of this new feature can be seen when the graphics card is rendering objects with a very big number of triangles or when using mesh instancing. In this case only a few DirectX commands issue a lot of GPU work. On the other side, when many DirectX commands are called, the performance improvement is not that big because Ab3d.DXEngine still needs to wait on the main thread until the graphics driver finishes processing the commands (DirectX Flush command needs to finish executing on the main thread). Anyway, in both cases the performance improvements (the time that you have on the main thread for your tasks) are significant. And what is best, you do not need to do anything except switching to a new version. 

 

2)

If you need even more performance and would also like that most of the drivers's work is done on the background thread, then you need to use DirectXOverlay presentation type. In this presentation type, the DirectX gets its own part of the screen (a hwnd handle) where it can present the rendered 3D scene when the graphics card finishes rendering. This presentation type is the fastest because the main thread is freed immediately after the Ab3d makes the last draw call by the Ab3d.DXEngine - both the driver's work and rendering are done in the background.

The problem with this presentation type is that it is impossible to render WPF controls on top of the 3D scene. Actually, WPF is not aware that the controls are hidden by the overlaid 3D scene so it will still render the controls, pass mouse events to the controls so they will be fully functional, but not visible.

The new version of Ab3d.DXEngine can solve the problem of hidden WPF controls in DirectXOverlay mode by using 2D sprites (also a new feature in this version) to show the static WPF controls (for example a TextBlock or a MouseCameraControllerInfo) or WPF controls that use Viewport3D (for example CameraAxisPanel or ViewCubeCameraController). The controls with Viewport3D are actually rendered by Ab3d.DXEngine. The trick is to render Viewport3D in a secondary DXViewportView control. This DXViewportView is created with the same DirectX device as the DXViewportView control that renders the main 3D scene. This way all DXViewportView controls can share the rendered results. For example, the secondary DXViewportView renders the CameraAxisPanel into a 2D texture and then this texture is shown on the main DXViewportView as a 2D sprite.

This can be done very easily with two new classes: WpfElementOverlay and Viewport3DObjectOverlay. What is more, the full source code of those two classes is available in the main Ab3d.DXEngine samples project.

 

The new version of Ab3d.DXEngine also comes with improved InstancedTextNode. This object can be used to render millions of characters. With the new version it is possible to change the individual texts and also remove some texts. For advanced users, the new version comes with a new InstancedMeshNode object that can show instanced meshes without using WPF's MeshGeometry3D (you can use any mesh derived from DXEngine's MeshBase). Also, the new version can prevent WPF's rendering thread exception (UCEERR_RENDERTHREADFAILURE) that may happen when the primary monitor has changed (for example when a laptop is connected to a docking station and uses more than one monitor; disconnecting the monitors can trigger a WPF excepton).

The Ab3d.PowerToys library also comes with a few new features and fixes. The new SphericalZoneVisual3D (and Ab3d.Meshes.SphericalZoneMesh3D) can show part of a 3Dsphere. This 3D object can be used to add a rounded end to a 3D cone or a 3D tube line. In addition, the FitIntoView method got two new overloads so you can call the method with passing a custom Rect3D (bounding box) or a custom list of 3D positions.

To see the full list of changes, check the history web pages: Ab3d.PowerToys history, Ab3d.DXEngine history.

 

I am also happy to inform you that the work on a new Vulkan based cross-platform rendering engine is also progressing very well. Here are two sample screenshots:




The first screenshot shows a test scene with the content of the memory dump command that shows advanced Vulkan memory management capabilities.

The second screenshot shows a simple 3D scene that is rendered in Linux and composed with Avalonia UI (Avalonia UI buttons are rendered on top of Vulkan 3D scene).

The current plan is to provide an alpha version in September 2021.

Tags: , ,

Ab3d.PowerToys | DXEngine