I would like to apply a shader effect to an image in c#/xaml.
I have found this example:
http://msdn.microsoft.com/en-us/library/system.windows.media.effects.shadereffect(v=vs.95).aspx
Which makes applying pixel shaders to an image pretty trivial. Unfortunately I cannot do the same thing with the windows 8 phone SDK.
Can I do anything this simple? I would like to avoid using DirectX if possible.
A Pixel Shader is a graphics function that calculates effects on a per-pixel basis. Depending on resolution, in excess of 2 million pixels may need to be rendered, lit, shaded, and colored for each frame, at 60 frames per second. That in turn creates a tremendous computational load.
In computer graphics, a shader is a computer program that calculates the appropriate levels of light, darkness, and color during the rendering of a 3D scene - a process known as shading.
A fragment shader is the same as pixel shader. One main difference is that a vertex shader can manipulate the attributes of vertices. which are the corner points of your polygons. The fragment shader on the other hand takes care of how the pixels between the vertices look.
As in most optimisations efforts, the performance of a pixel shader can be improved in two ways: by not running it at all if possible and, if not, by making it cheaper to run. So a first good step would to be to avoid rendering occluded triangles at all, using a CPU or GPU based solution.
Check the link below:
Creating a Lens Application that uses HLSL effects for filters
This solution uses SharpDX api (a C# DirectX wrapper).
I've tested recently and it works fine under emulator.
Unfortunally I didn't get the same results when applying outside a Game class. I already published a question here with no responses yet. :-(
Good luck!
Best regards,
Pieter Voloshyn
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With