source: 2015/26/MikkoL/JRPG/JRPG/JRPGContent/Ripple.fx @ 6281

Revision 6281, 1017 bytes checked in by mijoliim, 5 years ago (diff)

Wooo versionhallinta

Line 
1sampler ScreenS;
2
3float wave = 3.1415926535897932384626433832795/0.75;            // pi/.75 is a good default
4float distortion = 1;           // 1 is a good default
5float2 centerCoord = (0.5,0.5);         // 0.5,0.5 is the screen center
6
7float4 PixelShaderFunction(float2 texCoord: TEXCOORD0) : COLOR
8{
9        float2 distance = abs(texCoord - centerCoord);
10        float scalar = length(distance);
11
12        // invert the scale so 1 is centerpoint
13        scalar = abs(1 - scalar);
14               
15        // calculate how far to distort for this pixel 
16        float sinoffset = sin(wave / scalar);
17        sinoffset = clamp(sinoffset, 0, 1);
18       
19        // calculate which direction to distort
20        float sinsign = cos(wave / scalar);     
21       
22        // reduce the distortion effect
23        sinoffset = sinoffset * distortion/32;
24       
25        // pick a pixel on the screen for this pixel, based on
26        // the calculated offset and direction
27        float4 color = tex2D(ScreenS, texCoord+(sinoffset*sinsign));   
28                       
29        return color;
30}
31technique
32{
33        pass P0
34        {
35                PixelShader = compile ps_2_0 PixelShaderFunction();
36        }
37}
Note: See TracBrowser for help on using the repository browser.