New versions of Ab3d.DXEngine and Ab3d.PowerToys libraries have been published.
The new versions bring improved performance, new features and many bug fixes.
But let me talk about that later and start with a very interesting new sample that comes with Ab3d.DXEngine – a real-time HLSL shader editor. The following screenshot shows it in action:
On the left side you can see the HLSL editor with full syntax highlighting. The editor is using great AvalonEdit component. The right side shows some options and a real-time preview of the 3D scene and used shader.
The real-time preview means that after each change of HLSL text, the HLSL text is compiled and the new shaders are used to render the preview image on the right.
The opened ComboBox shows that the editor comes with 6 shaders that can be used as a simple step by step HLSL tutorial. The first sample shows how to render all objects with a single color (you can experiment with changing the color components). The following effects add some interesting coloring. And the final shader shows how to create a shader with directional light lighting and with added fog.
So, if you have not tried to program in HLSL, this is your best and easiest chance to try it out.
And if you want to change the 3D scene, you can just open the XAML editor and change the 3D objects defined there.
And there are more great news.
The new version of Ab3d.DXEngine has significantly better performance. In some cases (for example where many BoxVisual3D or similar objects are shown) the frame rate can be 3 times the previous frame rate. And already the previous version had some impressive performance. Also the time spend in the Update method is greatly reduced.
Also the problems with hardware accelerated 3D lines are now fixed. Because of some problems in the production version preparation, the previous version of Ab3d.DXEngine in many cases did not render the 3D lines with full hardware acceleration.
The biggest performance improvement in Ab3d.DXEngine can be achieved with using object instancing – rendering many instances of the same mesh. The performance is really amazing the following screenshot is showing 16.000 bunnies (each bummy model has 11.553 position) rendered at aroud 20 FPS (on i7 6700 and NVIDIA 970 GTX). Note that statistics in the lower right corner is showing that 184.848.000 positions are rendered:
The problem with instancing in the previous version was that it did not support hit testing. This has been improved in the new version. Now you can set the IsWpfHitTestVisible property on InstancedGeometryVisual3D to true and hit testing (also the EventsManager3D from Ab3d.PowerToys) will begin to work. Though this will increase the initialization time because WPF objects need to be created before WPF hit testing can work.
The new version also adds support for Binding on objects inside DXViewportView. For example, now you can bind IsVisible property on ModelVisual3D objects to CheckBox.IsChecked property.
The following is the full list of changes and improvements:
- Fixed using Binding on objects inside DXViewportView.
- Fixed rendering 3D lines with hardware accelerating geometry shader (instead of Ab3d.PowerToys's LinesUpdater).
- Improved support for transformations on TileBrush (used on ImageBrush, VisualBrush and DrawingBrush).
- Added IsWpfHitTestVisible to InstancedGeometryVisual3D - this allows WPF hit testing of instanced geometry (though this increased initialization time because WPF's GeometryModel3D objects needs to be created).
- Improved InstancedGeometryVisual3D so that it is not needed any more to call Update method when the InstancesData is set for the first time. Also fixed problems when the objects were not shown if Update was called before the InstancedGeometryVisual3D was added to Visual tree.
- Improved performance with moving some matrix calculations to vertex shader.
- Added support for rendering WPF's UIElement3D objects. NOTE: WpfUIElement3DNode can only show 3D models but does not support the input events on the UIElement3D (MouseEnter, MouseMove, etc.). Those events cannot be supported because Viewport3D control is not visible and does not provide the events to the UIElement3D.
- Greatly improved Update method call performance when many Visual3D objects from Ab3d.PowerToys are used (for example BoxVisual3D objects).
- Added IsCheckingChildrenForChanges field to WpfModelVisual3DNode that can be used to skip checking ModelVisual3D's Childen collection and improve Update performance.
- Added IsCheckingChildrenForChangesDefaultValue static field to WpfModelVisual3DNode - used to set the default value of the IsCheckingChildrenForChanges field.
- Fixed problems where wrong image was shown when multiple DrawingImage brushes or VisualBrshes were used.
- Prevented throwing exception when unsupported type of Visual3D (for example UIElement3D) or Model3D was used in the scene.
- Added Refresh method to Ab3d.DirectX.Material and its derived classes. This allows user to manually update the materials properties and its resources (textures are regenerated).
- Fixed hit testing on some Viewport3D objects (usually when the Viewport3D was removed from visual tree and then added to DXViewportView).
- Fixed using IsAutomaticallyUpdatingDXScene when the DXScene was created after the IsAutomaticallyUpdatingDXScene property was set.
The Ab3d.PowerToys library also got some fixes. The following is a full list of changes:
- Fixed showing 3D lines that were created with IsVisible property set to false. When later the IsVisible is set to true, sometimes the 3D lines were not shown.
- Fixed rendering 3D lines with arrows that were not rendered correctly under some circumstances.
- Fixed reporting MouseLeave event that was sometimes not triggered when CustomEventsSourceElement was used.
- Fixed changing BoxVisual3D and SphereVisual3D objects after Position is changed under some circumstances.
- Added GetCameraMatrixes to BaseCamera that can calculate view and projection camera even if TargetViewport3D is not assigned to the camera.
- Prevented throwing null reference exception in Dumper.Dump method when TextureCoordinates or Normals collection was null.
- Prevented throwing null reference exception that could sometimes occur in MouseCameraControllerInfo when in XAML designer.
The wrapper for assimp importer was also improved. The new library should read some models more correctly (especially models from fbx files). Also, the AssimpWpfImporter class now supports IDisposable interface. This means that it can be now easily disposed to release all managed and unmanaged resources. The following is list of all the changes in this library:
- AssimpWpfImporter now implements IDisposable and have new Dispose method to easily dispose all managed and unmanaged resources.
- Improved reading transformations - in case the transformation matrix is identity, the Transform property is set to null; in case the matrix is a simple translation, a TranslateTransform3D is created; in case of simple scale a ScaleTransform3D is created; otherwise a MatrixTransform3D is created.
- Improved reading 3D models that are stored in left coordinate system.
- Added ForceConvertToRightHandedCoordinateSystem property to AssimpWpfImporter and AssimpWpfConverter.
I hope that you share the excitement of the new versions with me. And I promise to bring you more great news in the future versions.