New Ab3d.PowerToys and Ab3d.DXEngine published

by abenedik 5. December 2024 20:07

As usual, shortly after a new .Net release, I am releasing new versions of Ab3d.PowerToys and Ab3d.DXEngine.

This is another bigger release with great new features and some important fixes. But before revealing what is new for Ab3d.PowerToys and Ab3d.DXEngine, I would like to present a brand new product.

As long as I am providing 3D graphics libraries, there has been a single most requested feature: provide support for importing .step and .iges files

Finally, I would like to announce that this is now possible with the new Ab4d.OpenCascade library. See the screenshots from the new CadImporter sample application:

CAD Importer with import settings
CAD Importer with assembly hierarchy

So far it was possible to use ReaderObj, glTFImporter or Assimp importer to import 3D models from many file formats. But all those file formats store their models as triangles or simple meshes that were defined by simple polygons. So after importing the meshes, it was relatively easy to show them using a rendering engine. But CAD applications like SolidWorks, CATIA, Autodesk Fusion 360, Autodesk Inventor, Pro/Engineer, Siemens NX, and others define their 3D models by using mathematically defined surfaces. All of those applications can store the models to .step or .igen files. Importing 3D models from those files first requires understanding all surface types and then triangulating them into meshes with triangles. Only after that can they be sent to the graphics card to render them.

The new Ab4d.OpenCascade library uses a third-party native OpenCascade library to read .step and .iges files and triangulate their models. This way the CadImporter class from the Ab4d.OpenCascade library can get 3D meshes that can be used by Ab3d.DXEngine (or Ab4d.SharpEngine) to render the 3D objects. The importer also preserves the names and hierarchical structure of the CAD parts (Compound or Solid). The faces and edges that define the parts can be also retrieved. For each edge, it is possible to get the original curve with its parameters. For example, you can get a location and a radius for a Circle (as seen in the image above); for BSpline curve you can get control points (Poles), weights and knots. What is more, it is possible to get the exact part volume and surface area (not from triangulated mesh but from actual mathematically defined objects).

The third-party OpenCascade library has its own license that allows free commercial use. The Ab4d.OpenCascade library can be used freely when the library is used with Ab3d.DXEngine or Ab4d.SharpEngine. The library provides the imported data in standard .Net types (int, float, double, simple arrays and structs) so it can be used by any other .Net code without Ab3d.DXEngine or Ab4d.SharpEngine. But in this case the source code for the Ab4d.OpenCascade library needs to be purchased (contact support for more info).

This is the first version of the importer, so your feedback is much appreciated. If you want some additional data from the .step or .iges files or would like to use some additional functionality from the OpenCascade library, please let me know.

The sample CadImporter application can be downloaded from CadImporter GitHub page.

 

And now to the new Ab3d.DXEngine. My favorite new feature is the new DynamicPlanarShadowRenderingProvider. It can render soft planar shadows with shadow darkness based on the objects' distance from the shadow plane. A screenshot best describes this:

soft and dynamic planar shadows

This looks even better when seen live in the sample because the objects are animated, and this updates the shadow dynamically.

The DynamicPlanarShadowRenderingProvider renders a shadow to a texture that can be set to a material that is shown by a 3D plane. When using static 3D objects (for example in ModelViewer sample in Ab3D.DXEngine samples), the shadow can be rendered only once and then the same texture can be shown as long as the 3D scene does not change. In an animated scene, the shadow can be updated on each frame.

This puts the DynamicPlanarShadowRenderingProvider somewhere between the already existing shadow providers: PlanarShadowRenderingProvider and VarianceShadowRenderingProvider. The PlanarShadowRenderingProvider is the simplest option for rendering shadows. It transforms all 3D objects into flat 3D models (using a shadow matrix). This creates a sharp shadow that is easy to render. The VarianceShadowRenderingProvider is a more standard shadow provider - it renders the objects from the light's position to a so-called shadow map that stores the distances from the 3D objects to the light. Those distances are then used when rendering 3D objects to determine whether the rendered pixel is in shadow or not. This can render shadow on any object (not only to a flat plane). The Variance term in the name means that a special technique that provides softer shadows is used. The shadow is always the same color, regardless of the object's distance. This is accurate for light that comes from a single source. But in reality, most of the light comes from ambient light that bounces around the walls and other objects.

In this case, the shadow is dark only when close to the object, but when the object is farther away, the shadow is not that strong anymore. This is what the new DynamicPlanarShadowRenderingProvider tries to achieve. 

The DynamicPlanarShadowRenderingProvider renders the shadow to a texture that can be shown on a 3D plane. The shadow can also be rendered to a transparent texture. This is also seen in the screenshot above. 

However, when using VarianceShadowRenderingProvider, it was not possible to render the shadow to a transparent 3D plane. You always needed to have an opaque object to see the shadow. But with the new version, there is a new VarianceShadowMaterial that can be used to render the shadow to a transparent texture (areas that are not in shadow are transparent).

 

The new shadow provider can improve the visual quality of the rendered scene. But when using 3D lines, the feature that provides the most significant improvement in the visual quality is super-sampling (SSAA). Graphics cards provide hardware support for multi-sampled anti-aliasing (MSAA), which significantly improves rendering quality. But super-sampling takes that to another level and can produce super smooth 3D lines. When SSAA is used, the 3D scene is rendered to a bigger texture that is then down-sampled to the final size.

But the cost of rendering a bigger texture can be quite significant. By default, Ab3d.DXEngine does not use SSAA (NormalQualityHardwareRendering GraphicsProfile is used). But many users changed that to HighQualityHardwareRendering and that uses 4xSSAA. This renders the 3D scene to a texture with 4 times as many pixels (width and height are multiplied by 2). Because in Ab3d.DXEngine the lighting calculations are done in a pixel shader, this means that 4xSSAA requires 4 times more pixel shader executions compared to rendering a scene without SSAA (and there is also an additional cost of down-sampling). Luckily, the graphics cards are incredibly fast and this is usually not a problem.

But what if I tell you that the new version can achieve almost the same visual quality as the previous version but at half the cost? The previous version supported only the following values for super-sampling count: 1 (disabled), 4, 16 and 64. Those values increased the width and height by a factor of 2, 4, or 8. However, after some research, I found out that almost the same visual quality can be achieved by using 2xSSAA - increasing the number of pixels by 2. In this case, the width and height of the texture are increased by a factor of 1.41 (a square root of 2). Rendering a scene with 2xSSAA can be done twice as fast as 4xSSAA because it requires only half of the pixel shader invocations.

So, the new version of Ab3d.DXEngine supports all values from 1 to 64 for super-sampling count, including 2, 3, and others. There is also a new OptimizedHighQualityHardwareRendering GraphicsProfile that supports 2xSSAA.

See the following screenshot for comparison:

super smooth lines sample

The top left part shows rendering without any anti-aliasing. The top right shows the improvement when using 4xMSAA (multi-sample anti-aliasing). The bottom left uses the new 2xSSAA (super-sampling anti-aliasing) + 4xMSAA. The bottom right uses 4xSSAA + 4xMSAA. The visual quality between the bottom two renderings is almost the same, but the left version is twice faster to render.

The following code enables the new OptimizedHighQualityHardwareRendering:

MainDXViewportView.GraphicsProfiles = new GraphicsProfile[]
{
    GraphicsProfile.OptimizedHighQualityHardwareRendering, // 2xSSAA + 4xMSAA
    GraphicsProfile.NormalQualitySoftwareRendering, // 4xMSAA
    GraphicsProfile.Wpf3D
};

 

The last new feature that I would like to describe in more detail is support for pixel hit-testing and point-cloud hit-testing.

From the first version on the Ab3d.DXEngine supports the standard hit-testing that generates a ray from a camera and mouse coordinates and then checks which triangles are intersected by the ray. Later a special hit testing that use ID bitmap was introduced. In this case, the whole scene is rendered in such a way that each 3D object gets a color that is calculated from the object's ID. This way, it is possible to check what color is under the mouse and from the color get the ID of the object. This is also very useful for mesh instancing where a huge number of meshes are rendered. In this case, it would take very long to check each mesh for ray intersections.

With the new version, it is also possible to render ID bitmap from pixels. To support that, set the new UseVertexIdColor property on the PixelEffect to true. This will render each pixel by a color that is defined from the index of the pixel.

To see that in action, check the new "Ab3d.DXEngine hit testing / Using Vertex ID Bitmap" sample. The sample also provides support for measuring distances on a point-cloud. See the screenshot:

point-cloud hit testing

The used ID bitmap can be seen in the bottom right corner.

 

There are also some other new features. And as always, this version also comes with some bug fixes. Let me mention just some of them:

  • fixed selecting lines with LineSelectorData when some lines are completely behind the camera,
  • fixed FitIntoView in some cases when parent ModelVisual3D objects have transformation applied,
  • improved edge line generation,
  • prevented showing render artifacts (may be shown as partially rendered image while camera is rotated rapidly),
  • prevented some exceptions like "childNode is already child of another SceneNode" and "StartBackgroundWaiting was called ..."

See the whole list of changes here and here.

To see the changes by yourself it is best to get the latest version of Ab3d.PowerToys samples and Ab3d.DXEngine samples. Check for NEW and UP icons (UP icons also provide a tooltip with additional information). If your updated subscription has already expired, you can still still get the new samples and start them. This will start a new trial version for the new version. If you have an expired subscription and have used the libraries for at least 2 years, contact me for a renewal discount (valid only in December).

 

Next week, I plan to release a new beta version of Ab4d.SharpEngine with many new features. Then until the end of February the new official version of Ab4d.SharpEngine will be released. If you want to purchase the Ab4d.SharpEngine, then now is the best time to do that because you can use a 30% discount in December.

And because we are already in December, I would like to wish you happy and peaceful holidays and all the best in the new year.

Tags: , , ,

Ab3d.PowerToys | DXEngine

New bug fix Ab3d.DXEngine published

by abenedik 12. July 2024 17:56

I would like to inform you that a new version of Ab3d.DXEngine has been published.

This is only a bug fix release that fixes the problems that were found after the last release. What is more, a new Ab3d.DXEngine.glTF library was also published (see below).

Here is a list of fixes:

  • Fixed changing IsVisible property on InstancedTextNode.
  • Improved hit-testing by preventing the creation of new objects on each hit test.
  • Prevented exception when the IsVisible of DXViewportView is set to true (from false) but the size of DXViewportView is empty (0, 0).
  • Corrected calculating Bounds (BoundingBox) for ScreenSpaceLineNode and ScreenSpaceLineMesh when IsPolyLine is true. Before the bounds were too big because the 2 generated adjacency positions that were required by the shader were also counted into the BoundingBox.
  • Updated Bounds in ScreenSpaceLineMesh when calling RecreateMesh.
  • Added new overload to RecreateMesh method in ScreenSpaceLineMesh. The new overload also takes BoundingBox as a parameter. It can be used when BoundingBox is already known - this prevents calculating new BoundingBox from new positions.
  • Fixed regenerating screen-space positions in some cases when the count of line positions is changed.

As promised in previous blog posts, a new fully managed glTF importer for Ab3d.DXEngine was published. If you are showing 3D models in your application, then you will now be able to use the new glTFImporter instead of Assimp importer. This will remove the dependency on the native Assimp library. If you are currently using some other file format (for example, .fbx or .dae), then you may consider converting that to a glTF file. There are many offline and online glTF converters that can be used for that task.

First, note that the new importer can read only the second version of glTF files (version 2). This new version is also used by most of the 3D modeling tools. glTF files come with two possible file extensions: .gltf and .glb. The  .gltf file extension represents a text json file with basic information of the 3D objects. Usually .gltf file also comes with a .bin file that stores the vertex and index buffers and embedded textures. It is also possible to embed the buffers and textures as base64 encoded text into the .gltf file. The other possible file extension (.glb) represents a binary version of the file. It has a smaller size and is the fastest to read. It also contains all the buffers and textures.

glTF 2 files store materials by using PhysicallyBased properties that use base color, metalness and roughness as base material properties. Ab3d.DXEngine also supports showing PhysicallyBasedMaterials. But for technical and business 3D objects the material usually use diffuse and specular colors (StandardMaterial in Ab3d.DXEngine or DiffuseMaterial in WPF 3D). Because of this, the importer in the Ab3d.DXEngine.glTF library has two special properties that can be used to define when the StandardMaterial with diffuse color is created from the PhysicallyBased properties:

ConvertSimplePhysicallyBasedMaterialsToStandardMaterials - when this property is true (by default) then  simple glTF's PhysicallyBasedMaterials that have MetallicFactor set to 0 and do not have MetallicRoughness texture are converted into StandardMaterial objects.

ConvertAllPhysicallyBasedMaterialsToStandardMaterials - when this property is true (false by default) then all glTF's PhysicallyBasedMaterials are converted into StandardMaterial objects.

And here are a few screenshots from the sample models that can be downloaded from glTF sample assets (https://github.com/KhronosGroup/glTF-Sample-Assets):

ABeautifulGame 3D model importer by DXEngine's glTF importer

FlightHelmet 3D model importer by DXEngine's glTF importer

In the future, I plan to remove some of the library's dependencies by embedding the glTF objects model into the library. I will also add an exporter that will be able to export an existing 3D scene to glTF file.

Tags: , , ,

DXEngine

Great new features in new Ab3d.PowerToys and Ab3d.DXEngine

by abenedik 12. April 2024 11:22

Even though a new Ab4d.SharpEngine, a cross-platform rendering engine, was released a few months ago, work on the Ab3d.PowerToys and Ab3d.DXEngine has not stopped. The proof of that is the just published version that brings many great new features and improvements. Here is a list of the most important:

  • Added many new options to render pixels and point-clouds.
  • Added hardware support to render millions of textures as billboards.
  • Added support for Screen Space Ambient Occlusion (SSAO).
  • Significantly improved performance of line selection and generating edge lines.
  • Added sample that shows how to render objects with glow.

The previous version of Ab3d.DXEngine already provided great support for rendering pixels and point-clouds. It was possible to render millions of pixels with various sizes and colors. There was an OptimizedPointMesh class that could optimize the rendering of large point-clouds. On top of that, the new version adds the following new options:

  • The pixel size can be defined in screen or world size. Before, pixel size was defined only in screen size, but now you can also define the size in 3D world size so when using perspective camera the pixels that are farther away from the camera are smaller.
  • Pixels can be rendered as rectangles or as circles. Before, only rectangular pixels were possible. Now circular pixels can be rendered and this looks nicer for some point-clouds.
  • It is possible to specify a texture that will be rendered on each pixel. This can be used to render millions of billboards that are always facing the camera.
  • It is possible to fix the up vector of each pixel so the pixels do not fully face the camera. For example, this can be useful when rendering trees that are always growing vertically and should not face the camera when the camera is looking straight down.
  • The Ab3d.DXEngine samples project comes with new PlyPointCloudReader and PlyPointCloudWriter classes (available with full source code). They can be used to read and write point-clouds from and to ply files.

Here are a few screenshots:

Importing point-cloud with more than 12 million pixels from a ply file.

(Point-cloud with 12 million points)

Cropping point-cloud and exportin it to a ply file.

(New point-cloud importer sample supports exporting a cropped point-cloud)

Rendering may 3D textures as billboards (the screenshot shows 15.000 tree textures, but modern GPU can also easily handle many more textures).

(Rendering may 3D textures as billboards. The screenshot shows 15.000 tree textures, but modern GPU can also easily handle much more textures).

 

Another big new feature is support for Screen Space Ambient Occlusion (SSAO). If you look around you, you can see all the places around the room. All receive at least some light even if the lights or windows do not directly illuminate them. This light is called an ambient light. To correctly render that light, we need to use ray tracing. But in real-time computer graphics, we can usually specify an ambient light with just one value. This will illuminate all the objects in the scene with the same amount of light. But if you look around you, you will notice that, especially at the corners, the amount of ambient light is much lower, and a shadow is visible. Those shadows can be approximated by using the Screen Space Ambient Occlusion. This reduces the amount of the applied ambient light in places that have some objects around them.

See the difference in the following two screenshots (one with and one without SSAO):

Screen Space Ambient Occlusion (SSAO) that can dynamically shadow ambient light
SSAO disabled

Note that to see SSAO shadows, you need to use a lot of ambient light and should not use camera's lights (set camera.ShowCameraLight to ShowCameraLightType.Never). If you are using camera's light, it can illuminate the areas dimmed by the SSAO effect. So, using fixed directional or point lights and strong ambient light is recommended to see SSAO shadows.

 

The next major change in the new version is not a new feature but a significant improvement of the existing functionality that many of you are using. The new version of Ab3d.PowerToys greatly improves the performance of line selection and generating edge lines.

Showing edge lines can significantly improve the clarity of the shown 3D model. But with the previous version, if you had complex 3D models, calculating edge lines was very slow. The new version significantly speeds up this process. For example, the next graph shows the time in ms that was needed to generate edge lines for a complex P51 oil rig model (3.7 mio triangles; 1000 individual models, some have more than 100,000 positions; CPU: AMD Ryzen 9 5900X):

Graph that shows performance improvement of new edge lines generation

The previous version required 13 seconds in .Net Framework 4.8 (11 seconds in .Net 8). In the new version, this is almost 50 times faster: 350 ms in .Net Framework 4.8 (280 ms in .Net 8).

So, when using the previous version the user needed to wait for quite a while until the edge lines were generated, but now this is hardly noticeable.

What is more, if you know that your mesh is nicely defined or does not have duplicate positions, you can speed up this process even further. Duplicate positions are very common because they are required to create sharp edges by defining different normals for each position (for example, BoxVisual3D defined 24 positions and not only 6). But if you know that you have a smooth mesh without duplicate positions, you can set the ProcessDuplicatePositions property to false to skip the step of finding and collapsing duplicate positions. Also, if you know that the mesh has nicely defined triangles where each triangle edge is fully covered by any adjacent triangle edge (except on the outer mesh borders), then you can set the ProcessPartiallyCoveredEdges property to false. This skips code to process complex meshes (for example, such complex meshes can be produced by Boolean operations). If users of your application can import any 3D model, then you should have all the settings enabled, but if you have fixed 3D models, then you can experiment by turning off some settings and get even better performance. What is more, the updated "Edge lines creation" sample in Ab3d.PowerToys samples has code that shows how to easily write and read the calculated edge lines to and from a file.

 

Another very commonly used feature was line selection. The line selection in Ab3d.PowerToys allows selecting lines when the mouse is close to the line (the user can specify the max selection distance). When you were showing a lot of lines or lines have lots of line segments, then the line selection could eat a lot of CPU cycles. Before, 2D screen coordinates were calculated for all line segments. Then the 2D distance from the mouse to each line segment was calculated. The line with the closest distance was the result of the line selection. The new version significantly improves the performance of line selection for lines that have more than 30 segments. In this case, only 2D screen bounding box of the line is calculated and if the mouse position is in the bounding box or close to it, then the 2D screen positions for all line segments are calculated. This can skip a lot of calculations because only lines that are close to the mouse are fully processed. Note that to use the new faster code path, you need to set the new CheckBoundingBox property to true. This is needed to preserve the behavior of the GetClosestDistance method. Before, this method always returned a valid distance value, but now, when CheckBoundingBox is true and when the mouse position is not close to the bounding box, then double.MaxValue is returned.

What is more, if you are using ScreenSpaceLineNodes instead of lines derived from Visual3D objects (this significantly improves the initialization time but is harder to work with), then you can use the new DXLineSelectorData that is the same as LineSelectorData but works with Vector3 structs instead of Point3D structs. This will give you even better performance because of reduced memory usage (using float values instead of double values).

The following screenshot shows a new sample that shows 5000 lines each with 5000 line segments and still achieving super-fast line selection time:

Super fast line selection where lines can be selected by specifying the distance to the lines (moving mouse close to the line).

 

The next new feature did not need any change in the Ab3d.DXEngine library but it just needed a special rendering setup. It is implemented in a new "Glowing objects" sample that can be found in the Advanced section of the Ab3d.DXEngine sample project. As its name suggests, it shows how to render glowing effect to objects with an emissive material. I know that this is not an essential feature, but I am sure that some of you will be able to use it to achieve some very nice visual effects.

Rendering glowing objects.

 

As always, there were many other new features, fixes and improvements. You can check them by starting the updated sample projects (Ab3d.PowerToys or Ab3d.DXEngine) and checking for samples with NEW or UP icons. You can get the list of all changed in Ab3d.PowerToys change log and Ab3d.DXEngine change log

 

When speaking about fixes, I would like to mention one nasty bug that occurred when many 3D lines were rendered (using multi-threader rendering), and after the size of the window was changed, then in some cases the lines could be rendered with invalid line thickness. If this also happens in your application, then please upgrade to the latest version. If this is not possible, then disable multi-threader rendering for 3D line or the whole scene (contact support for more info).

 

Lastly, I would like to mention that the new version comes with a new native Assimp importer that can import 3D models from many 3D file formats. The previous official version of Assimp importer v5.3.1 was released more than half a year ago (2023-09-25). The new version was released just a few days ago (2024-04-07) and comes with many improvements (https://github.com/assimp/assimp/releases). You can build the new version by yourself or get prebuilt dlls from the libs folder in the Ab3d.PowerToys or Ab3d.DXEngine samples.

 

Here, I would also like to announce that in the coming weeks, I will be releasing a fully managed glTF importer and exporter. This will allow you to import 3D models with full details without using a native Assimp library. Currently, if you do not want to use Assimp importer, you could use ReaderObj (part of Ab3d.PowerToys library) to read obj files or use Ab3d.Reader3ds library to read 3ds files. However, both obj and 3ds file formats have their limitations. Obj files do not support hierarchy and animations, are text only, and have limited materials. 3ds files support only 8.3 file names for textures. So, those two file formats could be used only in a limited number of cases.

On the other hand, the glTF 2 file format is a modern file format that was developed by Khronos group and can store meshes, hierarchies, materials, transformations and animations in a text or binary format. Suppose you distribute 3D models with your application and are currently using Assimp importer to load the models from various files. In that case, you will be able to convert the files into glTF (using Assimp importer and exporter or by using some other third-party or online glTF converter) and then distribute your models as glTF files. This way, you will not need to distribute native Assimp's dlls with your application anymore.

 

As seen here, the new version can significantly improve the performance of your application and the new features can make it even more visually appealing.

Now, the primary development focus will switch back to the new Ab4d.SharpEngine. I am really happy with the adaptation of the new engine. It seems that the first version already had enough features for many of your projects. Some new features have already been developed, but many are still to be implemented. I am planning to publish a new version in June 2024. So, if you have any feedback or a new feature request for the new version, now is the best time to provide that.

Tags: , , ,

Ab3d.PowerToys | DXEngine

New Ab3d.PowerToys and Ab3d.DXEngine version published

by abenedik 14. December 2023 16:06

New maintenance release for Ab3d.PowerToys and Ab3d.DXEngine has been published.

The new version does not come with any bigger new features and only brings a few fixes and improvements. Because of this, only the build version was increased, but the major and minor versions remained the same.

This version also comes with a new build for .Net 8.0. .Net 8.0 that was released a few days ago. At that point, I would like to thank the .Net team, which is doing a great job with each new .Net release. For example, the last version again came with many new performance improvements - see the article about that: Performance Improvements in .NET 8. This means that without any changes in the code, your code will run faster just by using the latest version of .Net.

I did a quick performance test by running the DXEngine multi-threading sample in .Net framework 4.8 and then in .Net 8.0. I used only single-threaded rendering with disabled commands caching and by showing 160.000 3D boxes and 3D lines. This means that for each frame the engine needed to set shader states and issue 160.000 draw calls. The results were astonishing. When running in .Net framework 4.8, the code required around 47 ms to render one frame. But when using .Net 8.0, only around 33 ms was needed for the same job. This is a 30% performance improvement. 

Ab3d.DXEngine performance in .Net 8.0

The new version also comes with an updated Assimp importer. There is a new native Assimp library (v5.3.1) and a new managed Ab3d.PowerToys.Assimp library. Using a newer native library provides a more accurate importer and can read more files correctly. On top of that the Ab3d.PowerToys.Assimp was also improved. This version adds support for reading files with non-ASCII file names. Also, now it is possible to read diffuse textures with emissive materials. And in case you were using hardcoded object names, then I need to inform you that the new version also comes with a breaking change because the new version may set the object names differently. The latest version tries to use names so that they are as close to the original name as possible. In case when an object group also defines its own meshes, the previous version set the name of the Model3DGroup by adding the "__Group" suffix. The new version set the Model3DGroup's name to the original name without any suffix. To prevent using duplicate names, it adds a mesh name as a suffix to the GeometryModel3D's name that is added as a child of the Model3DGroup. If you want to preserve the previous naming, then set the PreserveGroupNames property to false. Note, then in WPF, an object's name must start with a letter or underscore and can contain only letters, digits, or underscores. Because of this, the object names may still be different from the original names in the file. For example, "12-material#10" would become "_12_material_10".

The updated Assimp importer files can found in the libs folder on GitHub.

To see the list of other fixes and changes, see the change log web pages: Ab3d.PowerToys history and Ab3d.DXEngine history.

As mentioned last week, when the new SharpEngine was released, I am planning to release a new major version of Ab3d.PowerToys and Ab3d.DXEngine at the end of Q1 2024 . The following are planned new features:

  • Add support for Screen Space Ambient Occlusion (SSAO) - this can 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; especially for MultiLineVisual3D).
  • Add options to copy only part of the object ID bitmap from GPU memory to CPU memory - this would make using ID bitmaps 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.

If you have any additional requests or wishes, please contact us. Otherwise, stay tuned.

Tags: , , , ,

Ab3d.PowerToys

Major versions for Ab3d.PowerToys and Ab3d.DXEngine published

by abenedik 5. July 2023 20:27

I am happy to inform you that new major versions of Ab3d.PowerToys and Ab3d.DXEngine have been published.

The new release brings many great new features and one bigger breaking change.

The breaking change is the removal of the ViewCubeCameraController:

ViewCubeCameraController

A customer recently informed me that the ViewCube is patented by Autodesk. It seems that the patent is active only in the USA. See here: https://patents.google.com/patent/US7782319

Therefore I have decided to remove that control from the library. Instead of ViewCubeCameraController the new version of the Ab3d.PowerToys library now provides the CameraNavigationCircles control. See the screenshot of the new sample that demonstrates the CameraNavigationCircles:

CameraNavigationCircles Sample

 

And an animation showing that control in action:

CameraNavigationCircles animation

As you can see, the new control provides many customization options and can be used in many different ways. What is more, it can replace both ViewCubeCameraController and also CameraAxisPanel.

However, if you are already using the ViewCubeCameraController and would like to continue using it, then please first carefully study the patent, and consult with a layer. If you still want to use the ViewCubeCameraController, then please contact me and I will send you the source code for that control so you will be able to integrate it into your project.

 

Another major new feature of this release is improved support for line caps (line endings). Previous versions supported only arrow line caps. The new version adds support for additional arrow types, boxes, diamonds and circles. See the screenshot from the new sample that demonstrates that:

3D lines with different line caps

What is more, the Ab3d.DXEngine finally gets full hardware acceleration of all 3D lines, including lines with line caps. Before, lines with line caps were generated on the CPU (on each camera change the MeshGeometry3D of the line was regenerated and this was very slow). The new version solves that and moves the generation of the lines to the geometry shader. This means rendering millions of 3D lines with different line caps is now possible.

The new Ab3d.DXEngine also improves line initialization time, so if you define many 3D lines, the engine will show them faster. Also, the order in which lines and other 3D objects are rendered is defined by an improved sorting mechanism, so there should be fewer DirectX state changes when rendering, resulting in slightly faster rendering.

The new release also comes with a new build of native Assimp library that can be used to import 3D models from almost any 3D file format. Unfortunately, it seems that the version number of that library has been stuck at v5.2.5 for almost a year, regardless of hundreds of commits. To still be able to see what version is used, a new GitCommitHash property was added. It returns the Git commit hash of the version. For example, the Assimp library that comes with this release has GitCommitHash set to 0dcfe2f - from 2023-07-03. 

The new Ab3d.PowerToys.Assimp library now also supports reading lights and camera data from the imported file.

 

There are also many other improvements and fixes. Even though a lot of time was spent on the new Ab4d.SharpEngine, the list of changes is still very long - see the change logs for Ab3d.PowerToys and Ab3d.DXEngine.

Tags: , , , ,

Ab3d.PowerToys | DXEngine

New Ab3d.PowerToys and Ab3d.DXEngine with .Net 7 build

by abenedik 10. November 2022 19:58

New versions of Ab3d.PowerToys and Ab3d.DXEngine have just been released. The new versions bring many great new features and because they were released just after the .Net 7 release, the new versions also come with a new .Net 7 build.

Because this release is also linked to a new .Net version release, this blog post also shows some performance numbers related to running Ab3d.DXEngine by using different .Net versions. See the end of this blog post for more information.

 

Now back to new features. In the past there were many requests to improve the triangulator that was part of the Ab3d.PowerToys library. If we want to show a filled 2D shape, for example an ellipse, as a 3D object, we need to first convert 2D points to 3D points and then define the triangles that will connect the positions. This can be done by using a triangulator. The old version of Ab3d.PowerToys already has a triangulator, but it could process only simple polygons. This was improved in the new version so that the new triangulator can now process multiple polygons and also supports polygons with holes.

Triangulated 3D text

As seen from the image above, this allows generating a 3D mesh from any text (text is represented by a series of 2D shapes). The sample also shows how to generate a 3D mesh from multiple 2D shapes (ellipses, rectangles, paths with bezier curves, etc.). The lower part of the sample shows individual triangles that were generated. There is also a Slider control that can be used to show how the triangles are laid out from the first to the last.

In some cases the new triangulator can also be used instead of Boolean operations. This requires that the main 3D object has a constant height (for example represents a sheet of metal or wood). In case when user wants to subtract a cylinder or some other object that can be extruded from a 2D shape, then using the triangulator instead of a Boolean subtract operation will be much faster and will provide better results (fewer triangles will be created).

Another highly requested feature is better support for collision detection. By using bounding boxes it was already possible to do some collision detection. However, because the bounding box is only an approximation of the space occupied by the object, this was not very precise. The new version of Ab3d.DXEngine brings a new MeshCollider object that can be used to check if one 3D position is inside another 3D mesh. By checking all the positions of one mesh, it is possible to check if one mesh collides with another mesh. The new sample demonstrates that (when checking the sample use arrows, PgUp and PgDown keys):

MeshCollider

An interesting new material type that will greatly simplify work for some users is the new FaceColorMaterial. It supports defining different colors for each of the triangles in the mesh. Before it was already possible to achieve that by using a VertexColorMaterial. But this required that the positions of the mesh were duplicated so that each triangle used its own unique set of positions. Now this is greatly simplified because the original mesh can be used. What is more, by setting the alpha color to zero, the individual triangles can be discarded from rendering. The new sample nicely demonstrates that:

Face color material

Improving the performance of the Ab3d.DXEngine is a never-ending job. This version brings two new performance improvements. The first one is for those that use DXEngine's SceneNode objects and meshes. The new version significantly improves performance of hit testing because it can use OctTree objects on DXEngine's meshes. Before OctTree objects were created only from WPF's MeshGeometry3D objects. 

OctTree object organizes the triangles in a mesh in hierarchically organized 3D space regions so that when triangles are checked if they are intersected by a 3D ray, the number of checked triangles is much much lower. This makes hit testing almost instant even on huge meshes.

Now the DXScene.DXHitTestOptions.MeshPositionsCountForOctTreeGeneration property is also used when doing hit tests on DXEngine's meshes. Its default value is 512. This means that an OctTree will be automatically generated when the mesh has more than 512 positions. You can also manually generate the OctTree by calling the CreateOctTree method.

The second performance improvement will be great news for those who are rendering many polylines (lines where line segments are connected to each other). Multiple polylines are usually defined by a single MultiPolyLineVisual3D object. But though one object is used to define multiple lines, each line was still rendered by its own DirectX draw call. And if there were thousands of lines to render, it took quite some time to issue draw calls for each line. The good news is that with the new version, all the polylines can be rendered with only one draw call. This means that there will be almost no CPU cost for rendering any number of polylines.

As always, there are also many other improvements and fixes. See the change logs for more details here: Ab3d.PowerToys changelog and Ab3d.DXEngine changelog. Also get the latest samples (Ab3d.PowerToys.Wpf.Samples and Ab3d.DXEngine.Wpf.Samples) and check for UP and NEW icons to see new or updated samples.

 

And as promised before, let me show you some additional performance numbers. Each .Net version brings many performance improvements. There are new classes that can be used to write faster code. But also existing .Net code can run faster because each version improves the JIT compiler so it produces faster assembler code. The following graph shows how performance of the Ab3d.DXEngine can be improved when the application is run in a newer .Net version (running in .Net 4.8 is shown with a blue rectangle that represents 100% of the time; running in .Net 6.0 and .Net 7.0 executed the code faster and therefore the rectangles are shorter):

Ab3d.DXEngine performance in .Net versions

(1) "Multi-threading and caching" sample was run with showing 20000 boxes, using no background threads and disabled DirectX caching. The DrawRenderTime performance parameter measures the time that Ab3d.DXEngine needs to issue all DirectX draw calls. This requires going through all objects, checking their state, setting the DirectX state and calling DirectX Draw method. In this sample most of the time is spent in native DirectX code so the performance gains cannot be huge. But still, there is almost 10% better rendering performance just by using a newer .Net version.

(2) "Instanced animated arrows" sample was run with showing 1 million arrows. The graph shows values for the time that is required to calculate 1 million transformation matrices - each matrix is defined so that an arrow mesh will point toward the animated sphere. The values are based on highly optimized code (manually inlined and optimized math operations) that run on multiple threads (using Parallel.For).

(3) "Instanced animated arrows" sample showing 1 million arrows but this time the source code without any manual optimization is executed. The graph shows that the new JIT compiler can greatly optimize the generated assembler and in this case can provide a 25% performance boost.

(4) "Transparency sorting performance" sample shows the performance of different sorting algorithms that sort 3D objects to prevent transparency artifacts (the sample was updated to show 7200 instead of 720 boxes). The values under (4) show the difference of sorting that sort WPF 3D objects and is implemented by TransparencySorter from Ab3d.PowerToy library. Working with WPF objects is not very fast and there will be no changes in the WPF to make this faster. So it is great news that only using a new version of .Net can significantly improve the performance.

(5) The values here are again from the "Transparency sorting performance" sample, but this time showing the performance improvements of the transparency sorting from Ab3d.DXEngine. The source code for this sorting algorithm is already highly optimized, but still newer versions of .Net can squeeze some more juice from that.

So, Microsoft, keep up the great work!

 

And finally, the first open beta version of the new Vulkan based cross-platform rendering engine will be available before the end of this year! Let's conclude with the new logo for the engine:

Ab3d.SharpEngine logo

Tags: , , , , , ,

Ab3d.PowerToys | DXEngine

New versions of 3D libraries released

by abenedik 28. April 2022 19:57

I am happy to inform you that new versions of Ab3d.PowerToys and Ab3d.DXEngine libraries have been published.

This is a maintenance release with many improvements, fixes, and some new features.

The most interesting new feature in the Ab3d.DXEngine is added support for XRayEffect. The XRayEffect can render objects that look as they would be photographed by an x-ray. This can be useful when you work on a complex model with many parts and want to select one part while the other parts are just barely visible. In that case it is possible to make other parts semi-transparent. Another option that is available with the new version is to use the new XRayEffect or XRayMaterial. This works especially well when showing models with many triangles and with curved shapes. See example (this is a screenshot from slightly modified XRayEffect sample):

X-Ray effect on Ab3d.DXEngine

The new XRayEffect can be also used in the updated "Model Viewer" sample in the Ab3d.DXEngine samples (to use it check the new "Use X-Ray material" CheckBox in the second tab).

Another new feature can be used by those who use object instancing to render thousands of objects and want to do fast hit testing on the instanced objects. In this case, the new version allows rendering instance id bitmap from instanced objects. This generates a bitmap where colors represent the ids of the instances. By checking the color at a specific pixel, you can get the instance id that was rendered at that screen coordinates. This can also be used to do a rectangular selection or selection of the instance around the mouse cursor.

Also, the standard RenderToBitmap method got an improvement. With the new version it is possible to get direct access to the memory of the rendered bitmap. This way you can reuse the WritableBitmap or use any other method of using the rendered image. This is very useful when you are calling RenderToBitmap method very often because you can optimize and reuse the used objects (before a new WritableBitmap object was created on each call of RenderToBitmap method and this could generate many objects on the large memory heap).

The new version also improves stability in case of disconnecting an external monitor. Stability is also improved in some cases when rendering through a remote desktop.

The previous version introduced two-sided material that doubles the performance of rendering models that had the same front and back side materials. But this did not work in all the cases. This version fixes this issue.

There are also some other fixes and improvements. See the full list here: https://www.ab4d.com/DXEngine-history.aspx

 

The Ab3d.PowerToys library also got a few new features and improvements.

One interesting new feature is an improved algorithm for extruding a shape along a path. Now you can use two new options. One is to preserve the size of the shape at junctions and the other is to preserve the orientation of the shape's Y direction. See screenshot (the right side shows the extruded model using the new option):

Extrude a shape along a path

The new version of the library also comes with an updated Assimp importer and exporter. It now supports reading embedded textures and saving textures into fbx and glft files. There is also a new native Assimp library v5.2.3 that should improve the accuracy of importing and exporting files (https://github.com/assimp/assimp/releases/tag/v5.2.3)

To see the full list of changes see the change log here: https://www.ab4d.com/PowerToys-history.aspx

 

You can get the new version by updating the NuGet packages or by downloading the new evaluation or commercial version from your User Account web page. Note if you are using libraries from NuGet and you have recently renewed the updated subscription, then you will probably need to generate a new license activation code for the new version to work (this code can be generated from your User Account web page).

 

The list of new features is not as long as with some previous versions. The reason for this is that a lot of development effort is now spent on the new Vulkan based rendering engine (Ab3d.SharpEngine). This new engine is progressing very well. This engine will be fully cross-platform so the same code should be able to run on many different hardware devices. Recently we were able to run the code that works on Windows and desktop Linux on Raspberry Pi with a small touch screen attached - see photo:

SharpEngine on Resberry Pi with touch screen (pre-alpha)

Such a setup makes the engine great for controlling some industry machines or equipment.

The engine can also work on Android:

SharpEngine on Android phone (pre-alpha)

Many features from Ab3d.PowerToys and Ab3d.DXEngine were already ported to the new engine. But before releasing an alpha version, the core of the engine still needs some polishing and testing. I expect that the first alpha can be released in a month or two. The plan is to release a closed alpha version and later an open beta version. If you are interested in trying the new engine, please write me an email or feedback and you will be informed when the alpha version is available. This will allow you to test the engine on your hardware and on your devices. It will aso give you some influence on which features will make it to the first official and production-ready version.

Tags: , , , , , ,

Ab3d.PowerToys | DXEngine | SharpEngine