Writing your first ShaderEffect for WPF 3.5 SP1
WPF architect Greg Schechter was written a series of articles on the new hardware accelerated shaders recently released in beta form, as part of .NET 3.5 SP1 beta. This article includes some sample code that was enough to get me started down the path of writing a very simple shader effect - I've dubbed it "watery" but it's more just "wavy".
In this example the "waviness" of the effect is bound to the value of the slider at the bottom of the screen. One thing that I thought was very nicely done by the WPF team was the mechanism for passing parameters from WPF into the HLSL code using an attached property declaration like this:
public static readonly DependencyProperty WavinessProperty =
DependencyProperty.Register("Waviness", typeof(double), typeof(WaterEffect), new UIPropertyMetadata(0d, PixelShaderConstantCallback(0)));
The last part is the most important bit, which wires up the dependency property that has been defined in our C# WPF code to a constant in the [very crude] pixel shader HLSL code:
sampler2D implicitInput : register(s0);
float waviness : register(C0);
float4 main( float2 Tex : TEXCOORD ) : COLOR
{
float4 Color;
Tex.y = Tex.y + (sin(Tex.x * waviness)* 0.01);
Color = tex2D( implicitInput, Tex.xy);
return Color;
}
At the moment this sample is very much alpha, and sometimes does some very weird things to the contents of the window. Regardless I'm very impressed at how approachable the WPF team have made this stuff.
Categories:
#
Neat post
posted by
OJ
on
5/15/2008 8:12:32 AM
:
This is a great little demo on how easy it can be to add funky effects using pixels shaders :)
I'm sure you've seen this before, but in case you haven't (and for the benefit of those others who haven't), check out <a href="
http://channel9.msdn.com/ShowPost.aspx?PostID=403854">this</a> neat commentry and demo of the new WPF features.
Cheers!
#
Finally! Attractive Pixel Geometry For The Masses
posted by
Mr. Sustainable
on
5/15/2008 10:49:00 PM
:
I learned web development from the desktop publishing side of the world - which means that I had an eye for image quality long before I had an eye for clean code and stable applications. With information like this, I can return to my roots and produce products which make everyone happy.
#
timberland high top boots
posted by
timberland chukka boots
on
12/5/2009 4:04:08 PM
:
S11205I2
The son of wealthy and influential Athenian parents, Plato began his timberland chukka boots philosophical career as a student of Socrates. When the master died, Plato travelled timberland waterproof boots to Egypt and Italy, studied with students of Pythagoras, and spent timberland work boots several years advising the ruling family of Syracuse. Eventually, he returned timberland custom boots to Athens and established his own school of philosophy at the Academy.For students enrolled there, Plato tried timberland high top boots both to pass on the heritage of a Socratic style of thinking and to guide their progress through mathematical learning to the achievement of abstract philosophical truth.
http://www.officalsale.com/specials.html
#
EE
posted by
fang
on
3/20/2010 2:33:07 PM
:
One of my friend told me some information about Christian louboutin ,then i search them on the Internet,they are so beautiful.Christian Louboutin's designs have gained popularity among socialites and celebrities, several of whom have made public appearances sporting the signature red soles. For example, Christina Aguilera and Nicole Kidman were outfitted by the couture cobbler for their weddings.
The world is talking about Christian Louboutin, and the Hollywood stars lead the fashion. It is time to get yourself some.The Website including
discount christian louboutin
http://www.louboutindiscounting.comdiscount christian louboutin pump
http://www.louboutindiscounting.com/catalog/13/christianlouboutinpump
christian louboutin boots
http://www.louboutindiscounting.com/catalog/12/christianlouboutinboots
christian louboutin sandals
http://www.louboutindiscounting.com/catalog/14/christianlouboutinsandals
Yves Saint Laurent
http://www.louboutindiscounting.com/catalog/17/yvessaintlaurent
Jimmy Choo shoes
http://www.louboutindiscounting.com/catalog/16/jimmychoo