uniform extern texture ScreenTexture;
sampler ScreenS = sampler_state
{
Texture = <ScreenTexture>;
};
float wave; // pi/.75 is a good default
float distortion; // 1 is a good default
float2 centerCoord; // 0.5,0.5 is the screen center
float4 PS(float2 texCoord: TEXCOORD0) : COLOR0
{
float2 distance = abs(texCoord - centerCoord);
float scalar = length(distance);
// invert the scale so 1 is centerpoint
scalar = abs(1 - scalar);
// calculate how far to distort for this pixel
float sinoffset = sin(wave / scalar);
sinoffset = clamp(sinoffset, 0, 1);
// calculate which direction to distort
float sinsign = cos(wave / scalar);
// reduce the distortion effect
sinoffset = sinoffset * distortion/32;
// pick a pixel on the screen for this pixel, based on
// the calculated offset and direction
float4 color = tex2D(ScreenS, texCoord+(sinoffset*sinsign));
return color;
}
technique
{
pass P0
{
PixelShader = compile ps_2_0 PS();
}
}
This does produce a ripple effect, but not the desired result. The ripple begins a bit away from center position, and has an ugly trailing effect. I think this is down to the timing as well as some missing variables needed to make the desired effect. For an example, I am going for something like: http://www.youtube.c...h?v=Nr42AG1aPAY
I would like to be able to adjust the initial radius, number of ripples, length of the ripples before they dampen out, and the time it takes for them to reach their dampened state. If anyone has any experience with this, I'd love some help.
Thanks
Edit: I should also add that I am applying this effect to a Texture2D, and would like to make it a pixel shader only.






