| 1 | sampler2D Image: register(s0); |
|---|
| 2 | sampler3D Rand: register(s1); |
|---|
| 3 | sampler3D Noise: register(s2); |
|---|
| 4 | |
|---|
| 5 | float4 OldTV_ps(float4 posIn: POSITION, float2 img: TEXCOORD0, |
|---|
| 6 | uniform float distortionFreq: register(c3), |
|---|
| 7 | uniform float distortionScale: register(c4), |
|---|
| 8 | uniform float distortionRoll: register(c5), |
|---|
| 9 | uniform float interference: register(c7), |
|---|
| 10 | uniform float frameLimit: register(c8), |
|---|
| 11 | uniform float frameShape: register(c0), |
|---|
| 12 | uniform float frameSharpness: register(c1), |
|---|
| 13 | uniform float time_0_X: register(c2), |
|---|
| 14 | uniform float sin_time_0_X: register(c6) |
|---|
| 15 | |
|---|
| 16 | ) : COLOR { |
|---|
| 17 | // Define a frame shape |
|---|
| 18 | float2 pos = abs((img - 0.5) * 2.0); |
|---|
| 19 | float f = (1 - pos.x * pos.x) * (1 - pos.y * pos.y); |
|---|
| 20 | float frame = saturate(frameSharpness * (pow(f, frameShape) - frameLimit)); |
|---|
| 21 | |
|---|
| 22 | // Interference ... just a texture filled with rand() |
|---|
| 23 | float4 rand = tex3D(Rand, float3(1.5 * pos, time_0_X)); |
|---|
| 24 | rand -= float4(0.2,0.2,0.2,0.2); |
|---|
| 25 | |
|---|
| 26 | // Some signed noise for the distortion effect |
|---|
| 27 | float4 noisy = tex3D(Noise, float3(0, 0.5 * pos.y, 0.1 * time_0_X)); |
|---|
| 28 | noisy -= float4(0.5,0.5,0.5,0.5); |
|---|
| 29 | |
|---|
| 30 | // Repeat a 1 - x^2 (0 < x < 1) curve and roll it with sinus. |
|---|
| 31 | float dst = frac(pos.y * distortionFreq + distortionRoll * sin_time_0_X); |
|---|
| 32 | dst *= (1 - dst); |
|---|
| 33 | // Make sure distortion is highest in the center of the image |
|---|
| 34 | dst /= 1 + distortionScale * abs(pos.y); |
|---|
| 35 | |
|---|
| 36 | // ... and finally distort |
|---|
| 37 | img.x += distortionScale * noisy.x * dst; |
|---|
| 38 | float4 image = tex2D(Image, img); |
|---|
| 39 | |
|---|
| 40 | // Combine frame, distorted image and interference |
|---|
| 41 | return frame * (interference * rand.x + image); |
|---|
| 42 | } |
|---|
| 43 | |
|---|