Sign In

Navigation

On This Page

Silverlight 3 Shader Effects
InteliShade.Net: HLSL Syntax Highlighting and Intellisense

Archive

<September 2010>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

Categories

Blogroll

Contact

Send mail to the author(s) Email Me
MCPD
MCTS

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way


Copyright ©  2010
 Creative Commons License
This work by Jeff Klawiter is, unless explicitly stated in the article,  available under the Creative Commons Attribution 3.0 United States License.

Pick a theme:
# Wednesday, March 18, 2009
by Jeff Klawiter - Wednesday, March 18, 2009 5:41:54 PM (Central Standard Time, UTC-06:00)
With the release of Silverlight 3 Beta we can now run PixelShader effects on any control. This can produce some powerful stuff as shown during the Mix 09 Keynote this morning. I delved in as fast as I could to find out how to make your own and work with them in VS.

I downloaded the WPF shader library from http://wpffx.codeplex.com/ . I only imported the ShaderEffectLibrary so far, I have not tried the transition one.

I simply copied the EffectFiles, ShaderSource and EffectLibrary.cs files into my project and tried to compile.  Issues I ran into
  1. UIPropertyMetadata needs to be replaced with PropertyMetadata
  2. Color.FromScRgb needs to be replaced with Color.FromArgb and it's inputs run through Convert.ToByte
  3. MagnifyEffect.cs and SwirlEffect.cs reference classes that do not exist in Silverlight like the Vector class. I could have got them from reflector but in sake of time I didn't (that and being able to release this code)
  4. Getting the ps resources required a minor change to the Global static class. Basically changing the path to do a Relative URI lookup.
The basics here for doing your own shader effects is included save 1 thing. You need the DirectX SDK to compile your HLSL code. You can add a new build event or do it from the commandline. This is a good tutorial on how to do it http://windowsclient.net/wpf/wpf35/wpf-35sp1-hlsl-primer.aspx.

So the basics of doing your own Pixel shader in Silverlight is damn near identical as WPF. You inherit from the ShaderEffect class, load your compiled HLSL bytecode resource and expose any properties you need to modify as dependency properties.

Attached is my ugly but working example. I couldn't find anyway to bind to properties on an effect so I had to just do it by event.

SlShaderEffectDemo.zip

Comments [2] #      HLSL | Silverlight 3  |  kick it on DotNetKicks.com Shout it
# Friday, August 22, 2008
by Jeff Klawiter - Friday, August 22, 2008 12:29:45 PM (Central Standard Time, UTC-06:00)
I was playing around with shaders the other day and found the lack of syntax highlighting in Visual Studio to be a bit annoying. I had downloaded the Nvidia FX composer but it's a bit more complex than I really need. After a bit of searching google I came across InteliShade.NET.

InteliShade seems to have full syntax highlighting and InteliSense for base types. So far the InteliSense support is fairly simple. It will autocomplete object types and function names. It does not detect any variables or structures you've created nor does it give parameter completion on functions. I'm sure this will change as time goes on.

It looks like there's just one guy writing it and also doesn't seem to be open source. I'm sure if there's enough interest he may open things up. I've already begun talking this thing up. It wasn't too long ago Shawn Hargreaves gave a talk at our local XNA user group and he mentioned he didn't know of any VS HLSL sytnax highlighting and urged us to bug the VS team to add it. After finding InteliShade I did send him a quick email through his blog to let him know there is now an option.


Comments [0] #      HLSL | XNA  |  kick it on DotNetKicks.com Shout it