Published new Ab4d.SharpEngine for the browser

by abenedik 26. September 2025 13:10

I am pleased to inform you that a significant milestone for the AB4D company has been reached: as of today, we provide 3D graphics support for all platforms, including the browser.

Today, the first public beta version of the Ab4d.SharpEngine.Web library has been published on NuGet. Also, the source for the demo project has been published on GitHub. You can also check the live demo.

Here is a screenshot of the demo:

3D scene rendered with SharpEngine in a browser

Because the Ab4d.SharpEngine.Web library is using the same source code as the Ab4d.SharpEngine (using linked files), all the implemented classes use the same names and have the same properties and methods. This means that you can reuse the existing code from the desktop and mobile apps and use it for the browser. An exception is the features that are not yet supported in the web library. You can see the currently supported features on Roadmap and Implementation details.

The current demo demonstrates how to utilize Blazor WebAssembly to display 3D graphics in the browser. But because the Blazor project was created as a Progressive Web App (PWA; when creating a new project, check that the required CheckBox for PWA), the web application can also be installed on Windows, Android and iOS systems as a local app that can be started offline (without an internet connection). You can try this with the demo app. Developing PWA applications also provides an additional option for developing for desktop or mobile platforms.

What is more, you can use the existing Ab4d.SharpEngine license also allows you to develop for the browser.

Therefore, I would really like to invite you to check the new library. Please report any issues or recommendations to the GitHub issues or use any other communication tool (email, feedback form).

Tags: , , , , , ,

SharpEngine

New Ab4d.SharpEngine v3.2 and first working demo of web based rendering engine

by abenedik 12. September 2025 17:36

I am happy to inform you that a new version of Ab4d.SharpEngine, the cross-platform 3D rendering engine, was published today.

This version was actually planned to be released in November or December. However, due to the recent resolution of critical issues and the implementation of exciting new features that our users requested, I decided to publish a new official version sooner than planned.

Significant improvements have been made to improve the stability and reliability of the engine. Numerous new tests have been created to check these aspects. Some issues were resolved by modifying the Ab4d.SharpEngine, but there were also some issues that were due to bugs in the Vulkan validation layers or Intel drivers. To check the stability of the engine by yourself, one test is now available to all users. If you start the new samples for Avalonia, WPF or WinUI, then you will find a new "Advanced options" section in the Settings window. Among other options, there is also a new "Show samples TEST runner" CheckBox. When checked, a new TEST button will appear. If clicked, it starts showing random samples as quickly as possible (on ApplicationIdle). You can use that to see how long the engine can run.

This version also brings some major new features. The most interesting is support for rendering 3D models from scanned 2D images from MRI or CT scanners. See the following screenshots:

Volume rendering of 3D head model from MRI slices

The 3D model is rendered by using the new VolumeMaterialEffect that can show the 3D model from any camera angle, despite the slices being made from only one direction (one slice image is shown in the upper right corner of the screenshot). Based on the values from the scanned slices, it is possible to assign different colors and transparencies to different parts of the model - in this sample, this is used to distinguish between hard and soft tissue.

To show the 3D model, first, a 3D texture is generated from all of the scanned 2D images. Then the new CubeSlicer class is used to generate a mesh that slices a 3D cube from the camera's position to the other end of the 3D cube. Then this mesh is rendered by using the new VolumeMaterial that samples the value from the 3D texture (values from the scanned images) and converts the values into colors by using a transfer function texture (for each value in the scanned image, a color is assigned).

The sample can also be used to show how the 3D slices are generated. This can be best observed by yourself by starting the new sample and selecting "Show slice lines" or "Show slices mesh" options. You can also quickly see that by watching the following video.

The code from the sample can be used as a generic method for displaying 3D models from scanned 2D images. However, if you require any special settings or tweaks, please let me know, and I will try to adjust the code accordingly.

Another great new feature is support for super-fast hit-testing of complex meshes by using octree structures. This feature does not look that interesting, but it can be very useful for many of the users of the Ab4d.SharpEngine.

Usually, when performing hit testing, the engine generates a 3D ray from the mouse (or pointer) position to the 3D scene. Then the engine checks which SceneNodes may be intersected by the ray (by checking the bounding box). For those SceneNodes, the ray intersection is checked for each triangle of the SceneNode. When showing complex meshes with millions of triangles, this process can be very slow.

Octree structure helps solve that by organizing the triangles into a multi-level structure where each level divides the parent's 3D space into eight areas (or OctreeNode objects). The first level contains only one area, the second level contains eight areas, the third level 64 areas and the fourth level 512 areas (it is possible to define more than four levels; this is recommended for very complex meshes). Each of those areas has its own bounding box. So when doing hit testing, the area's bounding boxes are used to determine which areas are intersected by the ray. Then only the triangles in those areas are tested for intersection. This may reduce the number of checks by many thousands.

The following screenshot from the new sample shows how each level divides the space into 8 areas (see the bottom right corner to see how many triangles are in each of the levels)

The MeshOctree object can further optimize the distribution of the triangles by slightly expanding the areas so more triangles fall into lower areas. The following screenshot shows the distribution of triangles after that optimization (note that more triangles are distributed in the lower levels):

For example, the unoptimized image shows that the first level contains 728 triangles. Those triangles are always tested for intersection with the ray. But in the optimized versions, the first and the second levels have no triangles. To see the full distribution of triangles, the Octree sample prints the "Octree statistics" to the Visual Studio Output window. Here is a shortened part of that (the numbers in the list show how many triangles are in each area or OctreeNode):

Level 1: Triangles count: 0
Level 2: Triangles count: 0
Level 3: Triangles count: 113: 0, 0, 0, 0, 0, 7, 0, 0, ... (and other values)
Level 4: Triangles count: 3983: 4, 11, 52, 12, 8, 4, 12, ... (and other values)
Total triangles count: 4096

So, for example, if the ray intersects only the bounding box of the first area in the fourth level, then only 4 triangle-ray intersections are performed (11 intersection checks are done when only the second area is hit). Now, compared to 4096 checks that would need to be performed when no octree is used.

But using an octree is not free. For complex meshes, generating all the required OctreeNodes may take some time.

By default, the MeshOctree object is generated when hit-testing a mesh that has more than 512 positions. This is defined by the HitTestOptions.MeshPositionsCountForOctreeGeneration property. You can increase this value or set it to int.MaxValue to prevent automatic octree generation. If your SceneNode is not supposed to be hit-testable, you can also disable octree generation by setting the SceneNode.IsHitTestVisible property to false. You can also manually generate the octree by calling the CreateOctree method on the mesh object (do not forget to assign the created MeshOctree to the Octree property).

In the HitTestOptions class, there are also some other new properties that define the global settings for octree generation (for example, you can set the max level count and generate the octree at mesh initialization instead of hit-test time).

So, the octree structure can provide a huge hit-testing performance boost. However, if you do not need that and you experience a longer initialization time, you can disable the octree generation.

The last new feature that I wanted to mention was also developed for one of the customers and is also related to hit-testing. This customer is showing a mesh with millions of triangles and he needs to know which triangle is hit by the mouse. Usually, using OctTree would be perfect for that scenario, but he is changing the mesh (smoothing) on each frame. This means that on each frame, the MeshOctree needs to be regenerated. This was very slow and significantly impacted the frame rate.

The solution was to render the scene to an ID bitmap where each triangle would get its own color. So instead of regenerating the MeshOctree, the frame only needs to be rendered again and then the index of the triangle can be determined by the pixel color under the mouse. This is much faster and allows the customer to perform real-time smoothing of the triangles under the mouse.

The following screenshot shows the new sample that demonstrates the triangle hit-testing that uses the ID bitmap (the mouse is not shown, but the triangle under the mouse is shown by a red polyline):

This version also brings some other new features. As always, to see the list of all the changes and fixes, check the Ab4d.SharpEngine change log.

 

I know that at this time of the year, many of you have already been expecting to be able to try the first version of Ab4d.SharpEngine for the web browser. But because of the issues in the core Ab43.SharpEngine library, and because some time was spent implementing the new features that are mentioned here, the web version is not yet ready for the first public version.

However, a lot of work was still done for the web version. Therefore, I am very happy to announce that today I have published the web page where you can check how the web version of the Ab4d.SharpEngine works. You can check it in the Ab4d.SharpEngine for web pre-alpha demo page.

Here is also a screenshot:

This demo shows that the engine already supports rendering meshes with standard material (with or without a specular effect). It also supports hit testing, rendering 3D lines and camera manipulation with mouse or touch (on mobile devices).

When the demo page is first opened, it takes a few seconds until the page is loaded (most time is spent downloading and compiling the self-contained .NET WASM file). But on subsequent page loads, the 3D scene is shown immediately.

You can also test how the engine works when rendering many SceneNodes. With each click on the "Add many objects" 1000 BoxModelNode objects are added to the scene. You can observe the rendering times by opening the DevTools (F12) and check the log messages in the Console tab. You will see that even though the engine is running in the browser, it can be very fast - on my computer, it is rendering more than 5000 objects in around 7 ms (rendering individual objects and not using mesh instancing).

As seen from this demo, many of the major features are already implemented. The code just needs a little bit of additional work. Also, documentation about the web project setup and a quick usage guide need to be written. I think that this can be completed before the end of this month. Then a new NuGet package and the source code for the sample project will be published. This will also allow you to test the engine with your own web projects.

Some of you were asking about the license of the new Ab4d.SharpEngine for the web. The good news is that there will continue to be only one license for desktop, mobile and web platforms. This means that the existing customer will be able to start using the new web version without any additional costs.

Tags: , , , , , , ,

SharpEngine

New Ab4d.SharpEngine v3.1 published

by abenedik 7. July 2025 18:07

I would like to inform you that a huge new update to Ab4d.SharpEngine has been published. The Ab4d.SharpEngine is a cross-platform 3D rendering engine for desktop and mobile .Net apps.

Here is the list of the highlights for this version:

  • Improved rendering semi-transparent objects.
  • Added support for post-processing effects.
  • Added support for rendering object outlines that are rendered on top of other objects.
  • Added InstancedTextNode that can render millions of characters.
  • Added support for billboards (pixels with textures).
  • Added ModelOptimizer that can optimize rendering static objects.
  • Added support for rendering depth pre-pass rendering step.
  • Added .stl file importer and exporter and .obj file exporter (note: .obj importer was already available).

However, before I provide additional details about those changes, I would like to announce another significant update: from version 3.1 onwards, you can use the Ab4d.SharpEngine on desktop and mobile devices with the standard license. This means that it is no longer necessary to purchase an additional mobile development license when you want to develop for mobile devices. If you already have a standard license, then you only need to upgrade the version of Ab4d.SharpEngine to v3.1 and you will be able to use the library on mobile platforms.

And now let me describe the major changes in more detail. If you are using semi-transparent objects, you will likely notice that the colors of those objects are different in the new version. The problem with the previous version was that for some materials, the alpha value was applied twice, which made some objects appear too dark. See the comparison (the left image shows the previous version; the right image shows the new version):

SharpEngine semi-transparent object changes in v3.1

What is more, IsPreMultipliedAlphaColor property was added to VertexColorMaterial, PixelMaterial, PixelsNode and InstancedMeshNode. This makes it easy to define how the Color4 values are defined. By default, all values are defined without pre-multiplying the alpha value. But if you want to use alpha pre-multiplied colors, then you can set the IsPreMultipliedAlphaColor property to true. The alpha pre-multiplied colors are colors where the red, green and blue color values were multiplied by the alpha value. The graphics card requires that color format and the new version can now correctly provide the color in the correct format.

The next big new feature is support for post-processing effects. Post-processing effects are executed after the 3D scene is rendered and can utilize a fragment shader code to adjust the colors of the rendered scene. The following post-processes are available: SobelEdgeDetectionPostProcess, BlackAndWhitePostProcess, ToonShadingPostProcess, GammaCorrectionPostProcess, ColorOverlayPostProcess, ExpandPostProcess and GaussianBlurPostProcess. It is also very easy to add custom post-process effects. This is demonstrated with a custom HsvColorPostProcess that is available with full source code. The following screenshot shows the new Post-processes sample:

SharpEngine post-processing

The new post-processing effects provide the building blocks for another highly requested feature: rendering object outlines that are also visible behind other objects. This is possible by rendering the selected objects to their own render target and then using SobelEdgeDetectionPostProcess and ExpandPostProcess. Then the 2D image that is created by those two post processes is drawn on top of the standard rendered image. The following screenshot shows that in action:

SharpEngine model outlines sample

Another very impressive new feature is support for using instancing to render text. This is done by using the new InstancedTextNode. This SceneNode object can very efficiently render millions of characters. This is achieved by rendering all instances of a single character with a single draw call using mesh instancing. We all know that modern graphics cards are very fast. But it is hard to actually see that speed. The sample that demonstrates the InstancedTextNode can help us see how extremely fast the graphics cards are. For example, the following screenshot shows the sample with the default settings:

SharpEngine InstancedTextNode with 8000 texts

As you see, this shows 8000 individual texts where each text represents its x, y and z coordinate values in brackets. This requires rendering 108,000 individual characters. The 8000 value was chosen so that it is still possible to see individual texts. But this is far from what a modern graphics card is capable of. If you select the last option with 1 million coordinate texts, then after a few seconds of initialization, the following scene is shown (showing more than 13 million individual characters):

SharpEngine InstancedTextNode with 1 mio texts

It is really impressive to see how fast such a 3D scene can be rotated by the mouse and how many calculations are required to achieve that.

Another similar new feature is support for rendering billboards. Billboards are texture images that are always oriented towards the camera. In the new version, billboards can be rendered by using PixelsNode and assigning a texture to be rendered for each pixel. This can render millions of billboards very efficiently. The following screenshot shows the updated pixels sample that shows tiny tree textures instead of square pixels:

SharpEngine billboards

As it is demonstrated in the new "Pixels rendering options" sample, this also allows rendering circular pixels. In this case, a white circle texture is used for each pixel (the texture color is white, so the final circle color is defined by multiplying the white color by the pixel color).

I have helped many customers improve the performance of their applications with 3D graphics. In most cases, the most significant reason for slow performance was the large number of draw calls. A draw call is a command for the graphics card to render one object. In Ab4d.SharpEngine each SceneNode object usually requires one draw call. When the scene is defined by a few thousand small objects, then the performance may begin to worsen. The reason for this is that for each draw call, the driver and the graphics card must assemble a new job and execute it. This can take significant time. It is much faster to issue just a few draw calls, where each provides a lot of work for the graphics card.

This concept can be demonstrated by running the "3D Lines / Lines performance" sample. With this sample, it is possible to render millions of line segments. This works very fast when there are not a lot of lines and when each line has many line segments. However, if the number of line segments is reduced and the number of lines is increased, then the performance drops significantly. This indicates that issuing a small number of demanding draw calls is faster than issuing many simple draw calls. Instancing also greatly demonstrates this principle.

When you generate the SceneNodes objects by yourself, you can usually group many objects into a small number of more complex objects. But when you import 3D objects from files, those 3D objects may be purely optimized with many small objects. If you do not need to change those objects (they are static) in the 3D scene, or if the objects are only rarely changed, then it is now possible to optimize the objects.

This is done by using the new ModelOptimizer. It can be used to optimize the GroupNode by combining meshes in SceneNodes with the same materials into combined SceneNode objects. The new sample that demonstrates this loads an obj file with an old sailing ship. The ship model is composed of 3381 objects. When using ModelOptimizer, those objects are combined into 30 objects. That renders the scene much faster.

Another new optimization that is available with the new version is rendering the so-called depth pre-pass. In this case, all 3D objects are first rendered only with the vertex shader (fragment shader is disabled). This does not render any pixels but only fills the depth buffer. After that, the standard rendering is executed. But because now the depth buffer is already filled with the final versions of the depth, the fragment shader is now executed only for the pixels that will be actually visible. For all other pixels that are farther away from the camera and would be discarded, the fragment shader is not executed. Because all the lighting calculations are done in the fragment shader, this can provide a huge performance boost for 3D scenes with a lot of overdraw (many 3D objects are occluded by other 3D objects). This is especially important on slower graphics cards, for example, those on mobile devices.

The following screenshot shows the 3D scene that is rendered by the new "Depth pre-pass rendering" sample:

SharpEngine depth pre-pass sample

When this sample is run without depth pre-pass and then analyzed in RenderDoc, the following image shows the amount of overdraw:

SharpEngine no depth pre-pass overdraw

In the image, the white area represents pixels with more than 20 executed fragment shaders. Some pixels have even more than 50 executed fragment shaders. This means that to get the final color of that pixel, 50 invocations of the fragment shader were required. This can take quite some time.

When depth pre-pass is used, then all the pixels require only one fragment shader invocation.

I would like to conclude the description of highlighted features with improved object importers and exporters. The previous version of Ab4d.SharpEngine included an importer for .obj files. With an additional Ab4d.SharpEngine.glTF library it is also possible to import and export glTF files. To import other files, you need to use a third-party Assimp library. That library can import from many file formats. But because it is a native library (not written in .NET), it may be hard to distribute it with your application, especially if you want to create a cross-platform application. Because of this, the new version got a new .stl file importer and exporter. Stl file is very commonly used for 3D printing so including that into the Ab4d.SharpEngine makes it very easy to create helper tools for 3D printers. What is more, the new version also has an .obj file exporter. It can be used to easily export the 3D scene into an .obj file.

Those are only some of the new features. There are many more changes and fixes. To see all of them, please check the Ab4d.SharpEngine change log.

The easiest way to explore the new features is by getting the updated samples from GitHub (note the UP and NEW icons after the name of the sample to see the changed samples; the UP icon also contains a ToolTip with the description of the change).

For the conclusion, I would like to wish you a nice summer vacation (if you are living in the Northern Hemisphere).

After the vacations, many new exciting things are coming: I plan to publish the alpha version of Ab4d.SharpEngine for the web (for the Blazor Web Applications). And after that, new versions of Ab3d.PowerToys and Ab3d.DXEngine libraries will be released with some great new features.

Tags: , ,

SharpEngine

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

Ab4d.SharpEngine v1.0 published

by abenedik 8. December 2023 11:30

Ab4d.SharpEngine logo

Ab4d.SharpEngine v1.0 has been published!

The new cross-platform 3D rendering engine is ready for apps that work on Windows, Linux, macOS, Android and iOS. The engine uses Vulkan, which is a next generation graphics API that provides high-efficiency, cross-platform access to modern GPUs. The engine is also built by using the latest .Net technologies like Numerics and harware intrinsics. The combination of Vulkan and highly optimized .Net code provides super fast rendering. Based on long-time experience with Ab3d.PowerToys and Ab3d.DXEngine I have designed the API for the new engine to be very easy to use. Especially users of the Ab3d.PowerToys and Ab3d.DXEngine libraries should feel right at home.

The new engine can work on almost all devices that support .Net runtime. It can run on high end PCs and tiny Rasberry PI computers (with full hardware accelerated graphics). By using a software rendering LLVM pipe, the engine can also run on systems without a graphics card (for example, a web server, virtual machine or tiny embedded device). This provides many new very interesting options, for example, showing 3D graphics on a display that controls a CNC machine and runs on a Rasberry PI or some other embedded device. See here and here for more info.

The Ab4d.SharpEngine can be integrated into almost any UI framework. The following UI frameworks are currently supported: WPF, WinUI 3, Avalonia, MAUI, SDL / Glfw, LinuxFramebuffer. Better support for WinForms is coming soon. In all other UI framework it is also possible to render to an offscreen texture and than show that as a bitmap. Another proof that the engine is meant for any 3D developer is also that the engine supports any 3D coordinate system (y-up or z-up; left or right-handed; see the second screenshot below). What is more, the engine's main assembly, Ab4d.SharpEnine, does not have any third-party dependencies. To be able to provide great cross-platform capabilities, the engine even have a build-in png reader and writer, so you do not need to use platform specific bitmap libraries.

The first version of Ab4d.SharpEngine still lacks some of the features from Ab3d.PowerToys and Ab3d.DXEngine. But it should already have all the tools to create great apps with 3D graphics. Here are some of the screenshots:

3D model from fbx file with shown edge lines
Custom 3D coordinate system with Ab3d.SharpEngine
Ab4d.SharpEngine in an Avalonia UI application on macOS (Input events sample)
Ab4d.SharpEngine in an Avalonia application on Ubuntu Linux (3D lines sample)
Ab4d.SharpEngine in a generic SDL / Glfw application on Rasberry PI 4

The easiest way to start exploring the new engine is by checking the samples project that is hosted on GitHub: https://github.com/ab4d/Ab4d.SharpEngine.Samples. Note that some of the existing samples will be improved in the following days and many new samples are planned to be added.

The Ab4d.SharpEngine is distributed only by NuGet packages and cannot be installed by using a commercial version installer (as it was possible with other products). To use the engine it needs to be activated by calling the SetLicense method. The samples come with a special license that can be used only by the samples. To use the engine in your applications, you will need to get a trial license from ab4d.com/trial (no email is required) or purchase a commercial license and then activate the commercial license.

The purchase options provide the standard "Single developer", "Team developer", "Site developer" and "Corporate developer" options that define how many developers are allowed to use the library. The standard license allows developing applications for Windows, Linux and macOS - it is called a "Desktop developer" license. To develop apps for mobile devices (Android and iOS) an additional "Mobile developer" license is required. With a standard commercial license you are allowed to use the Ab4d.SharpEngin to create applications for uses that do not have the Ab4d.SharpEngine license. But if you want to create a commercial library that uses Ab4d.SharpEngine, then a new "SDK license" is required. Contact us for more information.

To celebrate the launch, there is a 20% discount for all Ab4d.SharpEngine licenses. The discount is valid until January 7th, 2024.

I know that some of the Ab3d.PowerToys and Ab3d.DXEngine users did not look at the development of a new engine with a lot of gratitude. That development meant that less time was dedicated to the existing engines. I admit that lately not a lot of work has been done for other libraries. But this will change now. Next week, a new maintenance version of Ab3d.PowerToys and Ab3d.DXEngine will be published. That version will have some fixes and smaller improvements already implemented in the last few months.

What is more, for Q1 2024 I plan to release a new major version of the Ab3d.PowerToys and Ab3d.DXEngine. The following are planned new features:

  • Add support for Screen Space Ambient Occlusion (SSAO) that will significantly improve the visual quality.
  • Add new options to render pixels and point clouds (world-size pixels in addition to screen-size; render circular pixels or pixels with custom textures).
  • Add support for rendering 3D lines and line segments to an object ID bitmap (can be used for faster line hit testing).
  • Add options to copy only part of the object ID bitmap from GPU memory to CPU memory - this would make checking for hit objects much faster.
  • Trying to improve the performance of calculating edge lines by using oct-tree.

For 2024, I would also like to introduce a new product that would allow importing 3D models from STEP and IGES file formats that are commonly used by CAD applications. Later, there would also be improved support for geometric and surface modeling that is based on mathematical surfaces and not triangles.

So, it looks like 2024 will be another very busy year.

Please try the new Ab4d.SharpEngine. I really hope you will like it and that it will help you build awesome apps and bring 3D graphics "where no 3D graphics has gone before" (adapted from).

Tags: , ,

SharpEngine

Ab4d.SharpEngine beta 2 comes with many new samples

by abenedik 18. April 2023 09:30

The second official beta version of the new cross-platform 3D rendering engine has been published. You can get the new samples from: https://github.com/ab4d/Ab4d.SharpEngine.Samples (on GitHub also click on the Watch button to be informed of future changes).

The new version comes with many new samples that demonstrate a lot of functionality of the new engine. There are samples that demonstate cameras, mouse camera controller, materials, lights, different 3D objects and lines, model importers and animation. The following screenshot shows the samples running in a WinUI 3.0 application:

Ab4d.SharpEngine Vulkan samples in WinUI 3.0 application

You can see that the samples are organized in a similar way as the samples for Ab3d.PowerToys and Ab3d.DXEngine.

Because the engine can run on multiple platforms and UI frameworks, most samples are now defined in a common samples project (Ab4d.SharpEngine.Samples.Common). That project uses a generic UI provider that can create UI elements like Labels, CheckBoxes, ComboBoxes, Sliders, Buttons and other elements that are required for the sample. Then the project for the specific platform references that common project and provides rendering of the UI. This way the same sample code can be used for WPF, WinUI and Avalonia. The Avalonia sample works on Windows and without any change in code the same sample also runs on Linux and macOS (see screenshot with Rider IDE in the back):

Ab4d.SharpEngine Vulkan samples in Avalonia application running on Linux

Ab4d.SharpEngine Vulkan samples in Avalonia application running on macOS

There are also two special samples for Android. They show only a single 3D scene. Their purpose is to demonstrate two different ways on how to initialize the engine in Android. From there on, the code to create and manipulate the 3D scene is the same as for desktop operating systems. The following screenshot shows the engine running in Android:

Ab4d.SharpEngine sample in Android application

The current version does not support iOS yet. The problem there is that AOT (ahead-of-time) compilation that is required for iOS does not support function pointers (https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-9.0/function-pointers) that are used by the engine to communicate with Vulkan. It is interesting that for Android or desktop it is possible to use AOT compilation and there function pointers work without problems. If you have any recommendations on how to use function pointers on iOS, I would be glad to hear that. Otherwise, it seems that a special build of SharpEngine will be required for iOS. That build would use a different and less efficient way to call Vulkan functions (using standard delegates and UnmanagedFunctionPointer attribute). This needs some additional research so the support for iOS has been moved to the next version.

The major goal of this beta version was to provide new samples that demonstrate how to use the engine. But there were also many improvements behind the scene.

The most important is updated code for sharing the rendered 3D scene with WinUI and Avalonia. In this case the 3D scene that is rendered by Vulkan stays in the GPU memory and is shared by the WinUI or Avalonia. The code for WinUI now uses SwapChainPanel instead of SurfaceImageSource. This is faster and better supported - SurfaceImageSource had problems on older computers or computers with integrated Intel GPU. In Avalonia the previous code for sharing texture created OpenGL vertex and pixel shaders and rendered the shared Vulkan texture to an OpenGL context. This was very complex and did not work well on all platforms. The developers of the Avalonia UI were also aware that this was not done well, so we worked together to define a new interface that can be used for sharing an external texture with Avalonia (after some private discussions with the developers the following was issued: External GPU memory interop (OpenGL, Vulkan, DirectX). The new version of the engine uses that new interface. This works very well so that shared texture can be used on computers where the previous approach did not work. What is more, Avalonia currently uses OpenGL to render its user interface, but there already exists a build of Avalonia that uses Vulkan to render the interface. This will be publicly available in one of the future versions. This means that it will be even easier and faster to share the 3D scene created with Ab4d.SharpEngine because whole application could use the same Vulkan device.

If you have not tested the beta 1 version, I would like to encourage you to try the new beta version. If you know how to create a 3D scene by using Ab3d.PowerToys, then it should be easy to work with the new library because the general concepts are the same. There are some differences in object names, but when working with the new engine, you will quickly see that the new API is much more polished than when using the Ab3d.PowerToys and Ab3d.DXEngine. The problem with those two libraries was that they were based on WPF 3D object model. That object model was extended by Ab3d.PowerToys and later by Ab3d.DXEngine objects. Because of this in those two libraries there exists multiple ways to define 3D objects: based on GeometryModel3D, Visual3D and on SceneNodes from DXEngine. Now, the 3D objects are all derived from SceneNode. All object grouping is done by GroupNode (instead of Model3DGroup, ModelVisual3D, ContentVisual3D, SceneNode). Also, when using Ab4d.DXEngine you need to use some tricks (using SetDXAttribute method) to define advanced properties on WPF materials. Now all material properties are directly accessible.

As promised before, the work on Ab3d.PowerToys and Ab3d.DXEngine will not stop. There are already many improvements and fixes in the current development version. Now I will focus on providing some additional new features and then prepare a new release. So if you have any recommendations, it is now a great time to provide that.

Tags: , ,

SharpEngine