

WPF objects, including Effects, are rendered using the DirectX engine. That's pretty much all you need to create all kinds of interesting pixel-based effects. Pixel ShadersĪ pixel shader is a short program that defines a simple operation executed on each pixel of the output image. Amazing speed comes with several trade-offs. Unfortunately there are several restrictions, such as limited number of instructions in one program, no ability to work with advanced data structures, limited memory management abilities, etc. There are even attempts to use the sheer computing power of GPUs for general purpose programming. There are several kinds of shaders - vertex shaders and geometry shaders are used when rendering 3D objects (not used by WPF Effects) and pixel shaders are used to perform simple operations on pixels. Small programs executed on GPU are called shaders. Modern GPUs are becoming more and more programmable and the range of tasks that can be executed on GPUs is growing (although there are several restrictions described below). The operations are executed with high amount of parallelism, which results in great performance. GPUs are not general-purpose, they are designed to perform simple operations on large data sets. The architecture of Graphic Processing Units (GPUs) is different than the architecture of CPUs. If you want to take advantage of hardware acceleration, you first need to know how the whole thing works. Anyway, there are probably more reasons why these 2 effects are implemented in a special way. Note: It is possible to create a single-pass blurring algorithm, but such algorithm is terribly slow compared to multi-pass blurring. However, the guys at Microsoft probably did a few dirty hacks deep inside the unmanaged core of the WPF rendering engine and created these two effects. Why are there only 2 fully implemented effects in the library and why don't these 2 effects derive from ShaderEffect? I can't answer the first question, but I can tell you what makes BlurEffect and DropShadowEffect so special.īoth DropShadowEffect and BlurEffect are using complex algorithms that require multiple passes, but multi-pass effects are not normally possible. The ShaderEffect class is the base class of all custom effects. The first two are ready-to-use effects included directly in the. It has three subclasses: BlurEffect, DropShadowEffect and ShaderEffect. The Effect class is the base class of all hardware accelerated effects. What needs to be assigned to the Effect property? The answer is as simple as it can be - it's an object of type Effect. It's strongly recommended to avoid using the BitmapEffect class or any of its subclasses! Effect and its Derived ClassesĪs stated above, you apply an effect to a control by assigning the control's Effect property (the property is actually inherited from UIElement, just in case you needed to know).

However, this API doesn't use any hardware acceleration and it has been marked obsolete in. The BitmapEffect class and its subclasses were originally supposed to provide the functionality of effects. However, not all of those classes are useful when it comes to hardware acceleration, in fact some of them are completely useless. NET classes that share the " Effect" suffix, and to make it even more confusing, they are all in the namespace. The fun starts when you decide to write your own effects.

As you can see, effects are so easy to use that you don't need any further explanation.
