다음을 통해 공유


3 Easy Steps to WPF Pixel Shaders. Template Project and Five Shader Samples (Twirl UI, Light, Blobs, Grayscale and Wave reflection)

In This Tutorial:

·         Template project and simple 3-step instructions to kick start WPF pixel shaders

·         Introduction to Pixel Shaders in WPF

·         Source Code for 3 pixel shaders

·         Links to 2 pixel shader sources on the web

Using Shaders in WPF: The Easy Way

Pixel shaders are a great way to enhance your WPF program in many ways. I show just few of the possibilities here and provide a good framework to start developing your own effects.

3 steps to kick start you with WPF pixel shaders:

1. Install DirectX SDK

2. Download and open the Shader template project from Nikola’s site: https://www.nokola.com/sources/ShaderEffectTemplate.zip

3. Start coding your effect in MyEffect.fx

Next: Read the Beginner’s Presentation to WPF Pixel Shaders

Downloads

Prerequisites: DirectX SDK from Microsoft.com

View the Beginner’s Presentation to WPF Pixel Shaders here: https://blogs.msdn.com/nikola/attachment/8924657.ashx

Download the template project here: https://www.nokola.com/sources/ShaderEffectTemplate.zip

Download these Pixel Shader samples: Twirl UI, Blobs and Lights: https://www.nokola.com/sources/ShaderEffects.zip Note that you have to enable each effect by itself for best view J Just comment out the other 2 effects when playing at the sample.

Check out these 2 cool pixel shader tutorials:

Grayscale effect: https://bursjootech.blogspot.com/2008/06/grayscale-effect-pixel-shader-effect-in.html

Wave reflection effect: https://rakeshravuri.blogspot.com/2008/07/wave-reflection-shader-effect-in-wpf.html

 Hope you like it!

Beginner’s WPF Pixel Shaders.pptx

Comments

  • Anonymous
    September 04, 2008
    PingBack from http://hoursfunnywallpaper.cn/?p=4615

  • Anonymous
    September 22, 2008
    The comment has been removed

  • Anonymous
    September 22, 2008
    Hi uditha, I found a response for your question on http://channel9.msdn.com/shows/Continuum/PixelShaderParts/ : "XNA is not compatible with WPF just yet.  Via reflection you can make it work, but with Vista requiring a 9Ex device for performance, you have a hard time getting 100% out of your hardware.  I have documented it on my blog. link: http://jmorrill.hjtcentral.com/Home/tabid/428/EntryID/259/Default.aspx "

  • Anonymous
    September 22, 2008
    Nikola Mihaylov explains what a WPF Pixel Shader really is and the code involved and making one. ...

  • Anonymous
    September 24, 2008
    The comment has been removed

  • Anonymous
    October 04, 2008
    We just published a codeplex project with source for > 25 Pixel Shader effects and ~35 Transition

  • Anonymous
    November 22, 2008
    The comment has been removed

  • Anonymous
    November 23, 2008
    Thanks for the note - I fixed the template project link!

  • Anonymous
    March 28, 2009
    Hi, Thanks for this useful post. What's important about deploying a wpf project which used pixel shader? I mean we should have DirectX on the client? Are we supposed to compile the .fx file on each client too or just we can use the generated .ps file?

  • Anonymous
    March 29, 2009
    Hi Ali, For deployment you just need DirectX on the client and you can use the generated .ps file without having to recompile it. Nikola

  • Anonymous
    March 29, 2009
    The comment has been removed

  • Anonymous
    May 26, 2009
    Hi Ali, I think you might be able to do something with edge detect filters in pixel shader only. Check this out for the filters: http://en.wikipedia.org/wiki/Canny_edge_detector http://www.pages.drexel.edu/~weg22/can_tut.html I haven't done it before, so I don't know if it would work - seems like it should though. Sorry for the late response! I just realized I haven't been receiving blog notification for quite a while...

  • Anonymous
    July 05, 2009
    The comment has been removed

  • Anonymous
    July 12, 2009
    oh my! this is so coooll!! thanks a lot Ali! I really like the shader effects

  • Anonymous
    September 11, 2010
    Thank you very much, Nikola. This really works (however I had some troubles with russian letters in project directory name - DirectX SDK didnt recompile the shaders). One more question iam interested in: can i use shaders to render into a bitmap (better - to a texture)? I want to use it after as ImageSource. Thanks!