Huge Ab4d.SharpEngine update with new open-source license

by abenedik 7. March 2025 13:32

I am thrilled to inform you that a major new version of the Ab4d.SharpEngine has just been published.

This version has many great new features, but let's start with a new licensing option: the new version of Ab4d.SharpEngine allows using the engine for free for non-commercial open-source projects.

There are multiple reasons why I decided to allow this option. One is that this will provide more samples and use cases on how to use the engine. This will also provide additional testing on additional devices and UI frameworks. However, one of the more important reasons for a free version is that I want to give people who like to work with 3D graphics a great and easy-to-use rendering engine. I have been passionate about 3D graphics for as long as I can remember. For example, when I was young, I liked to visit computer fares where I could stare for hours at Silicon Graphics machines that showed 3D CAD applications. This was like magic to me because at home I had only ZX Spectrum (btw, it had only 48 KM of RAM!). A few years later, when WPF was introduced, I was super excited because it also provided support for showing 3D graphics. I immediately started playing with that. And after a few months, this led to my first product - Ab3d.Reader3ds. So, if you are a similar enthusiast about 3D graphics, you can now use the Ab4d.SharpEngine for free. To apply for the free open-source license, use the online form.

To show what an interesting open-source project could look like, we decided to create a simple space simulator and use Ab4d.SharpEngine to show the planets and the moons. The simulator uses just a simple Newton's equation to calculate gravitation force: F = (G * m1 * m2) / (r * r). This equation is enough to simulate the whole solar system with all the planets and the moons. You can check the space simulator on its GitHub repo. But please be patient with this project as it is still in its early development form and has some issues. After those issues are fixed, we will be glad to accept PRs with new simulation scenarios and visual improvements.

Here is a screenshot from the Ab4d.SpaceSimulator running on Android tablet:

Space sumulator with Ab3d.SharpEngine in Andoid tablet

And now, here is a quick list of the major new features in v3.0:

  • Added support for super-sampling anti-aliasing (SSAA).
  • Added support for hardware accelerated line caps rendering and rendering hidden lines.
  • Added support for loading TrueType font files and showing text as 3D vector meshes.
  • Added support for async and background image loading and buffer upload.
  • Significantly improved performance of adding many small meshes.
  • Added support for showing a single Scene by multiple SharpEngineSceneView objects.
  • Added support for mesh triangle sorting.
  • Added support for Uno platform.

Just as its predecessor Ab3d.DXEngine, the Ab4d.SharpEngine also tries to provide superior render quality. By enabling super-sampling, you can now get super-smooth lines and text rendering. See the following image that shows a comparison of rendered lines with only multi-sampling (MSAA) and with additional super-sampling (SSAA):

Comparision of only MSAA to SSAA with MSAA

Super-sampling works by rendering a bigger image and then downsampling it to the final image. The 4x SSAA renders 4 times as many pixels (width and height are doubled). This also requires 4 times as many pixel shader invocations and can significantly affect the performance. Therefore, by default, 4x SSAA is used on dedicated graphics cards, 2x SSAA is used on integrated graphics cards, and no super-sampling is used on other devices. This can be changed by setting the value of the SupersamplingCount property.

Another great new feature is improved line rendering. The previous version supported only arrow line cap and even that was rendered as a series of additional lines. See the screenshot of how the old version rendered the line arrows:

Now, the line arrows are correctly generated in the geometry shader. This means that millions of lines with arrows can be rendered. What is more, it is also possible to render many other line caps:

Harware accelerated line caps in Ab4d.SharpEngine

Another line improvement is that it is now possible to render hidden lines - lines that should not be visible because they are behind 3D objects. Those lines can also be rendered with line patterns. This is very useful for CAD or similar applications:

Hidden line rendering

When using the current version of Ab4d.SharpEngine, I got some complaints that the text rendering was not well supported. The bitmap font does not look nice when the user zooms in to the text. Also, it is complicated to prepare your own bitmap fonts and to include new characters and symbols into the new bitmap font. Those issues should be solved by the new support for rendering vector fonts. Now, it is possible to use TrueTypeFontLoader, which can read TrueType font files (.ttf). After that the VectorFontFactory can generate vector text meshes and outlines from the glyph defined in the font file. This means that the font will look crisp even if you zoom into it. Also, it is very easy to include new fonts - just load the required ttf files. See the following screenshots:

Vector font from TTF file with outlines
Curlz vector font in Ab4d.SharpEngine
Chinese vector font in Ab4d.SharpEngine

Another common complaint about the current version was that it was slow to generate many smaller meshes. Also, uploading textures and bigger meshes blocked the UI thread. There was no way to upload that in the background.

Both those issues are solved with the new version. The reason why generating many small meshes was slow was that when uploading each mesh's vertex and index buffer, the code waited until the upload was completed. In this case, the transfer time was short, but the synchronization time (to signal that the upload is completed) was very long. Now, small mesh uploads are grouped into a batch upload so all uploads are done simultaneously. For example, creating 1000 pyramids, each with its own mesh now takes 15ms instead of 200ms.

On the other hand, when you need to upload a huge vertex and index buffer or want to upload a big texture, the new version now supports background upload with full async / await support (when supported by the GPU). This prevents blocking the UI thread. 

There are many ways to use background upload. One of the easiest ways to do this is to use the new constructors for StandardMaterial and SolidColorMaterial objects. They take the initial color and the texture file name. When they are used, the material is immediately created with the initial color. Then, the texture loading is started in the background, and when it is loaded and when the GpuImage is created on the GPU, the texture is set to the material. See the new "Advanced / Async upload" sample for more info.

The last major new feature that I would like to mention is that the SharpEngineSceneView object now has a constructor that takes a Scene as a parameter. This means that you can create a single Scene object and show it with multiple SharpEngineSceneView objects. Each can show the Scene with a different camera and view site. What is more, each SharpEngineSceneView can use different rendering techniques, for example, render the Scene as a wireframe. It is also possible to filter which RenderingLayers and individual objects are rendered in each view. The following screenshot shows that:

One Scene with multiple SharpEngineSceneView objects

There are many additional new features and fixes. To see the whole list of changes, check the change log for RC and beta 2.1 versions on the history web page.

I would like to conclude by looking into the future of the Ab4d.SharpEngine. It currently supports all desktop and mobile devices but cannot run in a web browser. This is going to change. Today, I would like to announce that a WebGPU based prototype was successfully developed. It took a lot of effort and struggle to be able to show 3D graphics by using Blazor WebAssembly. But now that the initial code works, the actual development can start.

The new engine will use WebGPU when the browser supports it. WebGPU is a new, high-performance API that is very similar to Vulkan API. It should provide much faster web 3D graphics than the old WebGL. Currently, WebGPU is supported by all major browsers except Safari. In cases where WebGPU is not supported (Safari and older browsers), I plan to provide WebGL fallback support.

This is the base that will allow the use of Ab4d.SharpEngine in a web browser. I am very excited about that because it will allow writing super fast 3D graphics code in C# that will be shown in any web browser. What is more, you will be able to use the same code for all possible platforms.

I am planning to release the first public version of the web rendering engine before the summer and the first official version before the end of the year. 

Here is a screenshot of the prototype (rendering a hash symbol with a solid color material - no light shading is supported yet):

WebGPU Blazor WebAssembly prototype

Tags:

SharpEngine

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.

Tags:

SharpEngine