Off-screen render targets?

Nov 5, 2010 at 5:32 PM


Is there a way to render the output of a shader to a off-screen render target with Bling?
I'm looking for an alternative for the WPF's RenderTargetBitmap.

Best regards,

Nov 6, 2010 at 12:47 AM

Depends. If you want to bypass WPF all together, then you can just use off screen render targets in DirectX. Check out the Diffusion.cs file/example in DirectX examples. You have to write your shader in DirectX rather than WPF, but this just means writing a quick vertex shader to indicate a simple one tile geometry (again see Diffusion.cs). This is a one way can output the results to WPF if you want, but because of burn through issues (WPF and DirectX are not very compatible) you have to use a separate overlay window to layer WPF elements ontop of the output (again, done in Diffusion.cs).   

But the nice thing about render target could render WPF elements to it. You can just render shader results to a DirectX buffer.  

Nov 8, 2010 at 1:05 PM

Thank you very much. I guess I can live with that. I really like the workflow with Bling!

But one thing I found when trying out the sample application: When compiling the NormalMap-Shader, I get an Exception that the number of instructions are too many for PixelShader 2.0.

Best regards,


Nov 9, 2010 at 1:08 AM

I forgot to mention: if you want to use a WPF render target buffer to output the result of a shader, the result won't be hardware accelerated (it won't run on the GPU). If you want to render off screen, your best option is DirectX.

Now for PixelShader 2.0, this is a limitation of WPF in .NET 3.5SP1,  WPF 4.0 uses 3 or 4.0, so you have a lot more instructions to work with. I haven't really updated Bling to 4.0 yet, there are some breaking changes in 4.0 that i have to work through (mostly to do with layout) as well as the need for to overhaul Linq Expression code and access a new custom build of the WindowsAPI code pack.