Sunday, April 10, 2011

How to apply a pixel shader to the video surface of DirectShow in C#

We must use Managed DirectX or the SlimDX libraries in out project and we must implement the IVMRImageCompositor9 interface provided by DirectShow.Net.

We then use our class by setting the image compositor on the VMR9 FilterConfig interface.

Only important and relevant parts of the class are shown.

The namespaces and definition:



Init the DirectX device through the DirectShow native pointer to the device:



Init the vertex buffer with a Fullscreen QUAD: two triangles that cover the whole suurface:



We implement the method CompositeImage, that is responsible for applying the shader.



Set the class on the VMR:



Implementing the device resetting and other DX needed tweaks is up to you.

No comments:

Post a Comment