Major new vesion of Ab4d.SharpEngine published

by abenedik 5. July 2024 12:48

I am really excited that I can present you a new Ab4d.ShareEngine version 2.0!

The version 1.0 was already very capable and could show 3D graphics on platforms from tiny Rasberry PI to mobile devices and high end PCs. But if you know the Ab3d.PowerToys and Ab3d.DXEngine libraries then you missed some of the features. Now, with version 2.0, many of those highly requested features are available.

Here is a list of some of the major new features:

  • Added support for rendering pixels and point-clouds. There is also a sample that can import point-cloud data from .ply and .xyz files.
  • Added ModelMover, ModelScalar and ModelRotator that can be used to move, scale and rotate selected 3D objects.
  • Added InputEventsManager that can be used on SceneNodes to subscribe to Clicked, Entered, Exited, Dragged and other mouse and pointer events.
  • Added MultiMaterialModelNode that can render a single mesh with multiple materials.
  • Added support for slicing SceneNodes with a 3D plane.
  • Significantly improved performance of generating edge lines and selecting 3D lines.
  • Added support for triangulation and extrusion of shapes with holes.
  • Added new sample that shows how to create a custom effect by using your own shaders.
  • Added full support for Windows Forms with new Ab4d.SharpEngine.WinForms library that provides SharpEngineSceneView control for Windows Forms.
  • Added fully managed glTF file importer and exporter that can be used on all platforms and does not require any native library (that is required by Assimp importer).
  • Added support for using Vulkan backend in Avalonia. This way the whole application (UI controls and 3D scene) is rendered by Vulkan. This requires Avalonia v11.1.0 (currently in pre-release version).

If you are following the development of Ab4d.SharpEngine, then you may be surprised by the new version number. I always said that the next version would be version 1.1, but now version 2.0 has been released. The reason for that is that there are also some breaking changes. In the previous version many classes, enum values and parameter names used the "mouse" word. But with the new cross-platform environment the "mouse" is no longer the correct word and has been replaced by "pointer" by many frameworks (Avalonia, WinUI). This has also been done in SharpEngine, for example: MouseCameraController => PointerCameraController, MouseButtons => PointerButtons, MouseAndKeyboardConditions => PointerAndKeyboardConditions, etc. In most cases the old class or enum values still exist but were marked as obsolete with a message about how to change its name. I know that such changes are not nice for users, but they must be done to modernize the API.

Here are some of the screenshots of the new version:

Point-cloud importer that can import data from .ply and .xyz files

ModelMover, ModelScalar and ModelRotator

Sliced 3D model

Triangulated and extruded 2D shape with holes

glTF importer

WinForms samples with 3D graphics by Ab4d.SharpEngine


Images are nice, but it's even better to see the new features in action. To do that, get the latest version of the samples from GitHub

Note that the Samples project is not updated only on each release but new samples may be added between releases. So, it is best to subscribe to changes or check the commit history of the Samples from time to time.

Most of the new features should be easy to understand and use. So let me describe in more detail only two of them.

3D models are usually created by a 3D modeling application and then saved in many possible file formats. When we wanted to show such 3D model in our application, the Ab4d.SharpEngine library provided two options. The first was to save the file in the .obj file format and the import it by using ReaderObj that is part of the core Ab4d.SharpEngine library. The problem was that obj file is missing many features (for example, object hierarchy and transformations) and is only text based, so files can be large and take longer to read. The other option was to save the 3D model to some of the common file formats like .fbx, .gltf, .dae, etc and then use Assimp importer to import the models. This works well for many file formats, but this requires the use of a third-party native Assimp importer. When you are developing a cross-platform application, this is a problem. The samples come with native builds for Windows and Linux. It is also possible to compile the Assimp library for macOS, Android an iOS, but this requires some special skills and you need to distribute all the native libraries with your application. A much better way would be to have a fully managed importer where only one dll can be used on all platforms.

Because of this, a new Ab4d.SharpEngine.glTF library was developed. It provides a fully managed cross-platform glTF 2 file importer and exporter. The glTF 2 file format is a modern file format developed by the Khronos group and can store meshes, hierarchies, materials, transformations and animations in a text or binary format. Many online and offline converters can convert to glTF from many other file formats. The new library can also export the SharpEngine's SceneNodes to glTF file (not all SceneNode types are supported yet). Please note that glTF 2 file saves materials as Physically-Based-Rendering (PBR) materials. This requires some transformations of the StandardMaterials to PBR materials and back. In the next version of Ab4d.SharpEngine I plan to add support for rendering PBR materials.

Another new feature that I would like to talk about is the support for creating fully Vulkan based applications by using the new version of Avalonia (v11.1.0-rc2 at the time of writing). Vulkan API is a cross-platform API that is used to communicate with the graphics card. It is used by the Ab4d.SharpEngine to render the 3D scene. But until now, there were no UI framework that would use Vulkan. Some of the frameworks use only DirectX (WPF, WinUI) or a combination of DirectX and OpenGL based on the current platforms (Avalonia, MAUI). In many cases this requires copying rendered 3D scene to some other format before it can be shared by the UI (but the rended texture can still stay in the GPU memory). In some cases, sharing is not possible and this requires copying the rendered image to the main CPU memory, creating a bitmap (WritableBitmap) and sending that back to the GPU by the UI platform. But with the new Avalonia, we can finally create an application that is 100% rendered by Vulkan. This provides very fast UI rendering and great integration with Ab4d.SharpEngine. Currently, this is possible only on Windows but in the future other platforms will be supported as well. You can test that by starting the new Ab4d.SharpEngine.Samples.AvaloniaUI.VulkanBackend solution.

Note that currently there are two versions of Ab4d.SharpEngine.AvaloniaUI libraries available. One has version 2.0.8951. This one is using the Avalonia version 11.0.11 (the last official version). Then there is another Ab4d.SharpEngine.AvaloniaUI library that has version 2.0.8953-rc1 (pre-release). It requires Avalonia version 11.1.0-rc2 (also pre-release). Those two pre-release versions are required to use Vulkan as a backend. When an official Avalonia version 11.1.0 is released, I will also provide a new version of Ab4d.SharpEngine.AvaloniaUI that will not be marked as pre-release.

To see the list of all changed in v2.0 check out the SharpEngine history web page.

Let's finish with a quick view into the future. 

Next week, I plan to publish a new bug fix release for Ab3d.DXEngine. In the past few months some bugs were fixed and it is now time to release that. I will also be adding new samples for Ab4d.SharpEngine and updating some of the existing samples. Before the end of the year I expect to release another new version of Ab4d.SharpEngine, Ab3d.PowerToys and Ab3d.DXEngine.

The plans for Ab4d.SharpEngine include work on the core of the engine with support for background resource creation (top priority) and multi-threaded rendering (hopefully). There will also be support for post-processing and improved pixel rendering options. I would also like to add support for Uno platform, PhysicallyBasedRendering effect and rendering 3D lines with arrows.

For both Ab4d.SharpEngine and Ab3d.DXEngine I would also like to provide support for importing STEP and IGES file formats that are commonly used by CAD applications.

There are lots of plans. But I am sure that many of you have some additional ideas and requirements. In this case please contact us.

And finally, I wish you a nice and relaxed summer and shiny 3D graphics in your applications.