![]() |
|
RenderToBitmap poor performance - Printable Version +- AB4D Forum (https://forum.ab4d.com) +-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4) +--- Forum: Ab3d.PowerToys (https://forum.ab4d.com/forumdisplay.php?fid=9) +--- Thread: RenderToBitmap poor performance (/showthread.php?tid=4430) |
RenderToBitmap poor performance - SLH - 10-18-2023 Hi, RenderToBitmap takes a long time (~60 seconds consistently) to render a 2048x2048 image. This seems excessive as in the onscreen view I can render in realtime. Is this expected behaviour? If so, are there any workarounds for it? I'm calling this routine: public RenderTargetBitmap RenderToBitmap(Brush backgroundBrush = null, int dpi = 96); Code: var viewport3D = new Viewport3D();RE: RenderToBitmap poor performance - abenedik - 10-18-2023 camera.RenderToBitmap method is using WPF's RenderTargetBitmap to render the 3D scene to a bitmap. RenderTargetBitmap may use software rendering for this. This is also probably why it takes much longer than when the 3D scene is shown on the screen - there hardware rendering is used. This is pure WPF code so I cannot do much to improve performance. If want better performance, then you will need to use use Ab3d.DXEngine. It uses a super fast DirectX 11 rendering engine that can render 3D scene that is defined by WPF 3D and Ab3d.PowerToys objects - so you do not need to change the code that defines your scene. With Ab3d.DXEngine you will be able to call DXViewportView.RenderToBitmap that is fully hardware accelerated and will work as fast as when shown on the screen. Ab3d.DXEngine also provides significantly improved visuals. See samples here: https://github.com/ab4d/Ab3d.DXEngine.Wpf.Samples RE: RenderToBitmap poor performance - SLH - 10-18-2023 Thanks for the prompt response. Apologies if not clear in the previous message, but it's an offscreen render. I have my on screen render with directx - which would explain why that is fast. Can the offscreen render be wrapped with directx too? RE: RenderToBitmap poor performance - abenedik - 10-18-2023 Yes, just call DXViewportView.RenderToBitmap instead of camera.RenderToBitmap - the later will use WPF's rendering. RE: RenderToBitmap poor performance - SLH - 10-18-2023 Looks like it works perfectly, thank you! (60seconds down to 0.1seconds). Thanks! |