Is WPF 3D good alternate of DirectX and OpenGL for complex applications? [closed]
Asked Answered
O

5

53

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.

Overcharge answered 20/1, 2012 at 12:19 Comment(0)
A
63

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?

Antisyphilitic answered 20/1, 2012 at 15:45 Comment(12)
Thanks for the answer, and my question is just a point of interest, but it would be helpful in future if i have to implement something in 3D.Overcharge
@Overcharge no problems. I'd suggest checking out this link helixtoolkit.codeplex.com as it seems to have a pretty good showcase on WPF 3D capabilities. Best regardsAntisyphilitic
@Dr.ABT SlimDx last release was in March 2012, therefore I am not sure it supports .net 4.5 for instance. Any alternative ? I'm working with vb.net and WPF, and I feel like I need something stronger for 3D.Extramural
We're getting good results with SharpDX (similar to SlimDX). By the way, .NET4.0 assemblies can be loaded in a .NET4.5 environment just fineAntisyphilitic
@Dr.ABT, is SharpDX still a viable option in 2016? My project has a 3D globe for displaying tracks (think airplanes) in real-time. It is an ancient product built on OpenGL 1.2. It works well for limited track numbers, but struggles as the track count increases. We're a .NET-based product, so I want to move to DirectX over OpenGL. Would love to find a good .NET-based graphics library, and SharpDX seems to fit the bill. Is that a good choice moving forward? Thank you for your time.Deerskin
We're using SharpDX as part of SciChart - a high performance WPF Chart scichart.com. We are also using our own C++ based engine wrapped to .NET using PLatform Invoke for 3D models. IMO SharpDX is pretty good, it's the integration of DirectX to WPF itself that is a bit shaky ...Antisyphilitic
@Dr.ABT , I'm very new to WPF in general and am looking into WPF 3D (sucks to start so late in the game figuring out what is the old way vs new way of doing things). I'm trying to build a carousal type control that can have 1000's of items. I looked at SharpDX, Helix Toolkit, and SharpDX toolkit (now deprecated). There's a tutorial here from 2008 where its all done in WPF: d3dal3.blogspot.ca/2008/10/wpf-cover-flow-tutorial-part-1.html . Was wondering if you can point me in the right direction. Would sharpdx / helix yield better performance? Whats the difference between the two?ThksSaguenay
Hello! Big question you just asked there in a paragraph. WPF3D offers ease of use over DirectX, but at expense of performance. In our chart software, we've written our own rendering engine for 3D Charts to get the performance, but it came at a cost. You might find for your use-case that WPF3D performance is acceptable and the cost/time-savings in using it could work in your favour. Have a look around for some rendering engines e.g. Unity3D which can shortcut the development time for DirectX but keep the performance. Good luck!Antisyphilitic
say, i have c++ sources for some d3d app. can i render it into wpf app?Pizza
Sure you can, but you will need to do some work to change the C++ D3D App to render to texture, then share that Texture with D3DImage. See github.com/Microsoft/WPFDXInterop for a sampleAntisyphilitic
Just wanted to say I appreciate your input, and experience. However, you shouldn't have been trying to render a million models anyway. Did you attempt Frustum Culling in the WPF3D version? That would have enjoyed likely given you the performance you were after.Orabelle
The application I mentioned with a million objects, did have frustrum culling and occlusion culling as well as level of detail. Some applications just have that much data to display.Antisyphilitic
C
10

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.

Combustible answered 13/8, 2012 at 11:14 Comment(0)
A
6

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.)

Animato answered 20/1, 2012 at 15:45 Comment(0)
A
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.

Atworth answered 20/1, 2012 at 15:46 Comment(0)
C
3

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.

Canales answered 20/1, 2012 at 16:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.