2
votes

I have a large scientific legacy application written in VB .NET 4.0, using winforms. I find the need for pixel shaders. In order to use pixel shaders in this situation, I assume I have to, for example, launch a WPF form, do some graphics magic, then disappear the form. That seems awkward. So, my question is "is there a way to use HLSL pixel shaders in a winforms application without WPF or XNA?

Thank you very much.

katherine

4
Are you talking about rendering 2D or 3D graphics in VB.NET using pixel shaders, or scientific computations (no graphics) using GPGPU (General Purpose GPU Computing)? - Dr. Andrew Burnett-Thompson
@Dr.AndrewBurnett-Thompson good question! Is the shader needed for visualization or computation? - MattDavey
... as if its GPGPU I would look at nVidia CUDA (Cg+nVidia only) or OpenCL (ATI, nVidia, CPU parallism) in that order of preference. I've worked on GPGPU projects before, specifically computation of Fast Fourier Transforms on GPUs. Best regards - Dr. Andrew Burnett-Thompson
Wouter -- thanks for the link. I had not found that one. I will look into it today. - user1123480

4 Answers

3
votes

You definitely don't want to use MDX (Managed DirectX is deprecated) or call into native DirectX (reinventing the wheel). You're much better off using SlimDX or SharpDX, two open-source and up-to-date libraries.

Likewise, if OpenGL is an option then there's libraries like OpenTK for that as well.

2
votes

Is HLSL really what you want? If it's a scientific application you might be better of with a more generalized shader language such as CG.

To answer your question though, WPF and XNA require HLSL, but the dependency is only one way. You best bet is probably to fall back to native C++ code and interface with DirectX or OpenGL that way - this native interface could be integrated with your VB4 app via COM. It is not a pretty solution, but legacy apps never are :)

EDIT: I just saw that you use VB.NET with .NET 4.0. I thought you used the veeery old Visual Basic 4! In that case, the answers which mention a managed DirectX wrapper (SlimDX) are your best option :)

1
votes

Yes, You can use HLSL shader without WPF and XNA by using DirectX, You need to create shader file(.fx) then you can use it in C# or VB.NET by using MDX library. Here is the sample would help you

-1
votes

You could use native DirectX. Xna on Windows is basically a DirectX wrapper. If you use the native DirectX library, you can probably figure most of it out on your own if you are familiar with Xna, but there are many guides. The hardest part to emulate is the Content Pipeline.

To do so, just download the latest DirectX SDK, install it, and add references to the Microsoft.DirectX.* libraries.