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