DirectX 11 rendering engine for Desktop .Net applications
Ab3d.DXEngine is a super fast 3D rendering engine that uses DirectX 11 and SharpDX and can be used in .Net Desktop applications.
The engine is written in managed C# and in HLSL (for DirectX shaders). DXEngine is very easy to use. You can use WPF 3D objects to define the 3D scene, cameras and lights.
What is more, you can use the Ab3d.PowerToys library and that gives you great tools and utilities for WPF 3D graphics and allows you to easily create CAD like or other business applications that require 3D graphics.
The rendered 3D scene can be fully composed with existing WPF objects that can be added on top of 3D scene of below the scene. The engine can be also used in WinForms applications.
Main Ab3d.DXEngine features:
- DirectX 11 based rendering engine with full hardware rendering support.
- The most versatile 3D engine - the same application can run on systems from high end graphics card (full hardware acceleration) to computers without graphics card (DirectX 11 software rendering). The same application can also run on an old computers with operating systems that do not support DirectX 11 (using WPF 3D rendering).
- Fully managed code that works with AnyCpu (x86 or x64) build targets.
- Super-fast and much more accurate per pixel lighting than in WPF 3D (WPF uses per-vertex rendering).
- Highly customizable: use custom shaders, rendering techniques, mesh data, etc.
- Render millions of hardware accelerated 3D lines (with custom thickness and color).
- Render reflections with environment and reflection maps
- Support for virtual reality with split-screen and anglyph rendering.
- Many post processing effects.
- Full Oculus Rift support is provided with Ab3d.OculusWrap library and DXEngine providers.
- Use new engine with just a few changes of the existing WPF 3D code. The engine fully supports Ab3d.PowerToys and Abd3.Reader3ds libraries.
Ab3d.DXEngine is not another game engine (like Unity) that forces you to use its game editor, its architecture and requires many hacks and tricks to be used in a standard .Net application. The Ab3d.DXEngine is a new rendering engine that is built from ground up with the purpose to be used in standard Desktop .Net applications.
Major new features:
- Added variance shadow rendering that can render nice soft shadows for one SpotLight or one DirectionalLight.
- Greatly improved working with frozen WPF objects. Before, DXEngine's objects created from frozen WPF objects (for example MeshGeometry3D or Material) were not reused when they were used by multiple Model3D objects. The new version caches the DXEngine's objects created from frozen WPF objects so they can be used by multiple DXEngine’s SceneNodes.
- Changed references to SharpDX libraries to use later versions of the library. The .Net 4.5 build of DXEngine now uses the latest version of SharpDX - version 3.1 (before 2.6.3 version was used); the .Net 4.0 build of DXEngine now uses SharpDX version 2.6.3 that support feature level 11.1 (before 11.0 was the last version that was supported by SharpDX). The 2.6.3 is the latest version that is supported on .Net 4.0.
- Added DXEngineSnoop diagnostics utility and full source code of Ab3d.DirectX.Client.Diagnostics project
- Various performance and stability improvements.
Other new features and changes:
- Improved performance when DXViewportView is resized.
- Improved "Complete rendering step" performance for scenes with many SceneNodes - especially for scenes with many BoxVisual3D or similar objects from Ab3d.PowerToys library.
- Added ReadZBuffer to DXAttributeType enum so you can call SetDXAttribute on any WPF 3D line Visual3D or WireframeVisual3D object. This allows rendering 3D lines with disabled Z-buffer reading (rendering 3D lines that are visible thorough other 3D objects).
- Added ReadZBuffer property to WpfWireframeVisual3DNode
- Improved performance of updating instance data for object instancing: Added new override of Update method that takes startIndex, count and updateBounds parameters to InstancedMeshGeometryVisual3D and InstancedModelGroupVisual3D - this can improve performance by updating data for only a few instances and can skip updating bounding box (use only when the instanced objects do not exceed the bounds of the whole scene)
- Added UseDynamicInstanceBuffer property to InstancedMeshGeometryVisual3D, InstancedModelGroupVisual3D, InstancedMeshGeometry3DNode and InstancedModel3DGroupNode - this allows using dynamic instance buffer (instead of immutable) that gives better performance for cases when the instance data are changed very often (for example once per frame).
- Added AfterUpdated event to DXScene - the event is triggered after the SceneNode objects have been updated and before the decision is made to render the next frame or not (subscriber can change the).
- When using RenderToBitmap and the DXViewportView is not shown on the screen, it is not needed to manually call Update method before each RenderToBitmap call.
- Prevented memory leak in RenderToBitmap and DXScene.CreateCustomRenderingContext methods.
- Added DisposeWithDXDevice method to DXDevice - it adds the specified disposable object to the list of objects that will be disposed when this DXDevice will be disposed.
- Added BeforeDeviceDisposed event to DXDevice - occurs just before the DirectX device will be disposed and after all other resources have been already disposed.
- Added ClearWpfObjects and AutomaticallyClearWpfObjectsAfterInitialization to WpfOptimizedModel3DGroupNode - this allows freeing the memory with data taken by MeshGeometry3D objects (other references to WPF objects also needs to be removed)
- Added ArrayStride to SimpleMesh to allow creating SimpleMesh from base types like float and byte (and not only from PositionNormalTexture and other structs).
- Improved handling of exceptions that happen during resizing - in case of sharing DirectX 11 rendered scene with WPF's DirectX 9 and if the error happens with resizing the DirectX 9 texture, DXEngine falls back to copying DirectX 11 rendered scene to main memory and using WritableBitmap to show it in WPF.
- Added ChildNodesChanged event to SceneNode
- Because of a new DXDevice based caching, the following static methods now require a new parentDXDevice parameter: Ab3d.DirectX.DXWireframeHelper.SetLineMaterial, Ab3d.DirectX.DXWireframeHelper.ClearLineMaterial, Ab3d.DirectX.Materials.WpfMaterial.SetUsedDXMaterial
- Added calling Loaded and Unloaded routed events on Viewport3D when it is used inside DXViewportView (because Viewport3D is not part of WPF logical tree, the Loaded and Unloaded events would never be raised; to make those two events work as in WPF 3D rendering, the DXViewportView raises it manually)
- Added DXDiagnostics.ReportLiveDeviceObjectsOnDispose property to allow showing a report of live objects in Visual Studio Output window when the DXDevice is disposed.
- Changed default value of preferedMultisampling paremeter for RenderToBitmap method to -1. This value means that the multisampling count from DXScene will be used.
- Fixed using RenderToBitmap when AnaglyphVirtualRealityProvider was used and when preferedMultisampling parameter in RenderToBitmap was different than DXScene's MultisampleCount.
New features and changes for advanced users:
- Added SceneNodeVisual3D that can show DXEngine's SceneNodes and can be added to WPF's Viewport3D Children. This allows creating SceneNodes without WPF Model3D or Visual3D objects.
- Added a new overload of RegisterBackBufferMapping method in the RenderingContext class. The new overload takes only a delegate and does not require to create a staging buffer and to pass it as a parameter. This allows very easy capture of next rendered frame - the next rendered frame is passes as a mapped staging buffer to the specified delegate.
- Added RenderingStepsGroup that can be used to group a few rendering steps together (by default the PreparePostProcessing and RenderPostProcessing rendering steps are grouped into a new RenderPostProcessingGroup rendering step)
- Added static GetLastRenderingStep, GetFirstRenderingStep and IsRenderingStepConnected methods to RenderingStepBase.
- Added ForEach to RenderingStepsList.
- Added ImmediateContext to DXDevice to simplify accessing ImmediateContext (before it was possible to get it from Device but this could lead to an undisposed reference).
- Added CustomRenderingQueue to DXAttributeType enum to easily set the CustomRenderingQueue to any WPF 3D object.
- Added CustomRenderingQueue property to SceneNode.
- Changed DXDevice.StandardBufferFormat and DXDevice.StandardDepthStencilFormat fields from const to static so that it is possible to change the default back buffer format (B8G8R8A8_UNorm - required by WPF) and default depth stencil format (D32_Float).
- Added new override of DXScene.CreateCustomRenderingContext method that also takes custom format and can be used to create rendering context with some other back buffer format.
- Added a new CustomRenderingContext class that is derived from RenderingContext and also allows changing some additional context data line FinalBackBuffer and FrameNumber.
- Added CreateCustomRenderingContext method to DXScene that takes existing back buffer, its render target view and depthStencilView to create RenderingContext that can be later used in RenderScene method.
- Added new overload of CreateCustomRenderingContext that also takes virtualRealityProvider as parameter.
- All overloads of the CreateCustomRenderingContext method in DXScene now return CustomRenderingContext class instead of its base class (RenderingContext).
- Changed constructor of RenderingContext to take SwapChain as parameter - SwapChain can now be set only from constructor because the protected SetFinalBackBufferAndSwapChain method was replaced by a SetFinalBackBuffer method.
- Added UnregisterAllBackBufferMappings to RenderingContext to unregister all registered delegates (this simplifies the unregister process; before the only way to unregister was to use UnregisterBackBufferMapping that required the delegate as parameter and this prevented defining delegate as an anonymous methods)
- Removed MaterialEffect property from WpfGeometryModel3DNode - if you were using it, then create a new material and override the Effect on it instead.
- Changed SceneNode class with converting the following pubic methods from virtual to non-virtual: AddChild, InsertChild, RemoveChild, RemoveChildAt, ReplaceChild, ClearChildNodes (to prevent virtual call in constructor; to get notified about the change of ChildNodes you can now use the new ChildNodesChanged event instead of overriding the Add or other methods)
- TextureCache.GetTextureFromFile method does not load texture file any more in case the file was not loaded and cached before (reason: ShaderResourceView.FromFile is deprecated for Windows 8 and not used in SharpDX v3+ any more - https://msdn.microsoft.com/en-us/library/windows/desktop/ff476283(v=vs.85).aspx)
- Removed DXCubeMap constructor that takes ddsFileName as parameter. If you were using dds file for cube map, create the ShaderResourceView from dds by yourself and set the created ShaderResourceView in the call to SetDXAttribute with DXAttributeType.Material_EnvironmentMap (reason: ShaderResourceView.FromFile is deprecated for Windows 8 and not used in SharpDX v3+ any more)
- Moved IsD3DPerformanceEventGroupingEnabled property from DXScene to DXDiagnostics.
- Added overload of Add method on Bounds class that also takes Vector3 object and adds the specified position to the current bounds.
- Added CalculateBounds to SimpleMesh and automatic bounds calculations when the vertext buffer is created from PositionNormalTexture or PositionNormal structs.
- Improved classes derived from MeshBase (GeometryMesh, DXMeshGeometry3D, DXMultiMeshGeometry3D, ScreenSpaceLineMesh and SimpleMesh) to correctly set their Bounds and to have similar public method to recreate mesh.
- Prevented camera problems when one DXDevice was used for multiple DXScenes.
- Fixed showing WireframeVisual3D when its Transform is set.
- Added support for semi-transparent SolidModelColor in WireframeVisual3D.
- Fixed rendering 3D lines in RenderToBitmap method when the parent DXViewportView is not shown.
- Fixed setting Viewport3D property on DXViewportView to null.
- Fixed problems with not showing the content of DXSceneView that could occur sometimes when DirectXImage presentation type was used and the DXSceneView was recreated (previously the content was updated after resize of DXViewportView)
- Fixed not showing 3D image that occur sometimes for computers with multiple graphics cards (usually laptops with dedicated graphics card) when DirectXOverlay PresentationType was used on Windows 10.
- Fixed not updating 3D image when DXView was loaded without a valid size (for example after a breakpoint in VS)
- Improved caching Textures and prevented using a lot of memory for textures cache that could occur because of too little cache cleanups.
- Fixed rendering textures with ImageBrush Opacity set to values lower than 1 for scenes with 3 or less directional lights.
- Fixed setting DXViewportView.UseViewport3DCamera property in code.
- Fixed calculating camera positon from MatrixCamera. Also added SetCameraPosition method to prevent calling invert on view matrix when GetCameraPosition is called.
- Added showing diagnostics window from main DXEngine samples project
- Added Shadow rendering sample
- Added BackgroundRenderingSample
- Added ReadZBuffer sample
- Added "Multiple scene views" sample - how to use the same DXDevice to share resources with multiple DXViewportViews
- Added sample on how to manually create SceneNodes
- Added sample on how to use custom fog shader that is created with Shader factory sample project.
- Improved PolyLines sample and Performance test
- Added sample of global exception handler that gets detailed system information when DXEngine or SharpDX exception happens
- Added WinForms sample project that shows 3 different ways on how to use DXEngine in WinForms application.