Question

I hope I do not make my first mistake with my first post.

I am writing a library for several graphical effects and filters (for example Sobel or Gauß mask). Because of the low Speed, doing this on the CPU, I wrote some shaders with the Shazzam tool.

My concret Problem is, that I am not able to use this shader in C#. In the Internet I found only advice how to apply a pixelshader as a effect in XAML directly to a element, which is not usable for my application, because this makes it impossible to apply several shaders on one Image, which is needed, for example the Canny Edge Detector.

To illustarte this issue a Little pseudo-code, which should Show, what I expect from the method.

PixelShader somePixelShader  = new PixelShader(pixelshader.ps);
somePixelShader.Input = Bitmap;
somePixelShader.Height = 200;
somePixelShader.Width = 800;

somePixelShader.Execute();
Bitmap = somePixelShader.Result;

As you see, everything should be done in C#.

Perhaps you can help me with my issue.

Was it helpful?

Solution

You can make a copy of the current effect output as a bitmap with RenderTargetBitmap, then submit this outputted image as the new input for the next effect, rinse, repeat.

Update : after a small (and inconclusive) test, this will not work : Can't render pixel shader to RenderTargetBitmap! Please help!

OTHER TIPS

Check out these white papers for step-by-step instructions + examples on how to compile and use a pixel shader in WPF or SL.

You may also want to check out the WPF Pixel Shader Effects Library here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top