First impression on WPF+Pixel Shader
Several weeks ago I was excided to learn that WPF now (in .Net framework 3.5 SP1) supports pixel shader. There is a video on Channel9 about this stuff.
Thanks to Niola's guide, it is very easy to use HLSL to write pixel shader for WPF. Here is a simple pattern that I wrote in HLSL and now it is my screen saver.

The math is very simple. The phase is the delta distance between the pixel on the scene and two nearby points behind the scene.
|
sampler2D input : register(s0); float2 size : register(c0); //size of the screen, in pixel float3 location:register(c1);//relative location of p2, controlled by WPF animation #define Pi 3.1415926
float4 main(float2 uv : TEXCOORD) : COLOR { float3 p1={0.5,0.5,2}; float3 p2=p1+location; float3 current={lerp(0.5,uv[0],size.x/size.y),uv[1],0}; float delta=(distance(p1,current)-distance(p2,current))/0.005; float4 result0= tex2D(input, uv.xy); float interfere=((1-cos(2*delta))/2+1)/2; result0*=interfere; result0.a=1; return result0; } |
Here is the same pattern that I wrote in DOS's era.

How time flies...