Is WPF 3D good alternate of DirectX and OpenGL for complex applications?

33,805

Solution 1

Good question. The answer is it depends!!

On a more useful note, I can say this: A few years ago I developed a CAD-style 3D rendering application in OpenGL. This had to display CAD models of oil rigs with up to 1,000,000 objects and allow the user to zoom right into detail, or zoom out, move objects, etc... I can say with some certainty that WPF wouldn't be suitable for this type of application as it would just be too slow. This application was developed using C++/CLI and bridged from a .NET GUI (Toolbar, window) to C++ to OpenGL (render surface) and even that introduced a performance hit over a native C++/OpenGL application due to thunking. So, if you want the highest performance, you cannot beat native C++ with DirectX or OpenGL.

WPF can provide high-performance 3D graphics and smooth interactivity for simpler 3D applications. For instance, a 3D chart surface or a 3D carousel, even a 3D CAD model viewer so long as the model was fairly simple. Once the object count starts to ramp up you will notice the rendering engine can't handle it - that's when you need to switch to a rendering engine that allows direct access to the GPU.

For a halfway house solution (managed + DirectX), try SharpDX. This is basically an open-source implementation of Managed DirectX and is extremely powerful and versatile. The performance hit of managed vs. native C++ is minor (~5%) and when done right, managed DirectX can be extremely performant.

Something we've done is integrate DirectX directly with WPF via D3DImage. We've achieved this in a WPF 3D Chart Control which uses DirectX11 for the drawing (not WPF3D). This shares directly from native DirectX to WPF but you can get equally good results with SharpDX, which we've used to create a high speed WPF Drawing Plugin here.

For a showcase of WPF3D I suggest you try this link. As you notice WPF3D can make extremely visually appealing and sometimes complex examples but you won't find any 1,000,000 object oil rigs in there ;)

Finally, what is it that you wanted to do in WPF 3D? Just a point of interest or do you have a specific project to implement and want to know if it would be suitable?

Solution 2

There are two models of 3D Graphics: 1. Pipeline or infinite loop approach (3D Games, Hard level 3D Cad systems with 100.000 and more objects - meshes) 2. Smart abstract model WPF3D with classic support of OOP without any OnDraw, OnPaint methods. It is very important to use Media3D methods of WPF by right way. So most important thing is without any OnDraw, OnPaint.

You must analyze your application type and features and choose.

It is not so correct opinion about WPF 3D as for most simple application, but for full managed OOP objects. For example, take a look on screenshots on my site TIMO Structural CAE

It is full managed 3D WPF app.

Solution 3

If you really want to do something complex, you're actually better off using an established graphics engine (typically developed for games), rather than using DirectX or OpenGL directly. The WPF 3D engine provides a similar level of abstraction, though it has a drastically smaller feature set (you're still going to have to work pretty hard if you want shadows, reflections, refraction, bump maps, skeletal animation, etc.)

That said, I've used it successfully for visualization of an in-house 3D simulation tool and it's more than adequate for my needs. It performs fairly well even with a crowded scene and the basic lighting support is enough to clearly visualize the geometry. It was also quite easy to get working, which is a big plus in my book (didn't have much time to invest in developing visualization.)

Solution 4

If by WPF's 3D you mean it's ability to display hardware accelerated 3D graphics, then I would say yes. If, however, you mean WPF's 3D framework; then I would be tempted to say no.

I haven't used a great deal of the WPF 3D framework, but from what I have used, I have found it to involve a lot of hard-coded points. That being said, there is probably ways around that, but I generally don't think the framework was ever built with advanced 3D graphics in mind (such as modelling tools and game engines).

However, what I have found it to be good at, is displaying 3D rendered content and smoothly integrating the rendered content with it's UI composition system. I have used WPF extensively in this way as an application host for rendering and manipulating 3D content - specifically in terms of a 3D modelling context.

For such situations, you can use the D3DImage control embedded within a WPF application to allow DirectX content to be rendered directly on your application. You can either render to this surface using DirectX itself, or a managed wrapper such as SlimDX. The latter of which I have found to be very good as it supports DirectX versions 9, 10 and 11, and it is a fairly thin wrapper so a lot of the DirectX API is usable in almost the same way.

Overall, I would say it entirely depends on your required usage of the 3D system.

Solution 5

While the answer is of course it depends. I will be bold and say that WPF 3D is great for learning, simple needs, and integrating 3D into an otherwise 2D application.

Since you're considering WPF, I'll assume you're looking at using C# to write something that installs on Windows. In addition to what others recommend, I suggest looking at XNA, which is not part of WPF, but a subset of which is available in Silverlight 5 (if you want to stick with XAML).

I've programmed in OpenGL with C, DirectX in C++ and Managed DirectX (obsolte) and WPF 3D. WPF 3D provides a very high level of abstraction, provides a lot of convenience features, and is suitable for some applications. I've used it in the past on an application that combined 2D and 3D graphics and it worked well for this application. In this case, I needed arbitrary clipping planes, which was a feature that wasn't available, and it was easier to manually do the clipping than to use a different API that provided this feature but lacked much of the high level convenience.

Share:
33,805
SpeedBirdNine
Author by

SpeedBirdNine

I am a software engineer and hobbyist gamer. Other than that I like reading and exploring new technologies. Me on Twitter My favorite questions: What is the single most influential book every programmer should read? Why is subtracting these two times (in 1927) giving a strange result? MVVM: Tutorial from start to finish? What is the worst gotcha in C# or .NET? Learning game programming byte + byte = int… why? Fastest sort of fixed length 6 int array Where do you go to tickle your brain (to get programming challenges)? What modern C++ libraries should be in my toolbox? Why is my program slow when looping over exactly 8192 elements? Learning to Write a Compiler

Updated on July 09, 2022

Comments

  • SpeedBirdNine
    SpeedBirdNine almost 2 years

    I have used WPF's 3D capabilities for learning, and for a few implementations, and I have found it to be very capable, and I am also learning DirectX 11, and it is very tricky compared to using 3D classes in WPF. I have only used WPF 3D for very basic stuff, my question is:

    Is WPF 3D equally good for advanced applications such as 3D modelling tools, game engines and 3D simulations etc to be an alternative to DirectX and OpenGL?

    If there is anything else in the same league, please mention it too.