Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/Cg/OldTV.cg @ 12181

Last change on this file since 12181 was 12115, checked in by wiesep, 6 years ago

Changed folder structure, deletet some unused files and cleaned up code

File size: 1.6 KB
Line 
1sampler2D Image: register(s0);
2sampler3D Rand: register(s1);
3sampler3D Noise: register(s2);
4
5float4 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
18   // Define a frame shape
19   float2 pos = abs((img - 0.5) * 2.0);
20   float f = (1 - pos.x * pos.x) * (1 - pos.y * pos.y);
21   float frame = saturate(frameSharpness * (pow(f, frameShape) - frameLimit));
22
23   // Interference ... just a texture filled with rand()
24   float4 rand = tex3D(Rand, float3(1.5 * pos, time_0_X)) - 0.2;
25   rand -= float4(0.2,0.2,0.2,0.2);
26
27   // Some signed noise for the distortion effect
28   float4 noisy = tex3D(Noise, float3(0, 0.5 * pos.y, 0.1 * time_0_X)) - 0.5;
29   noisy -= float4(0.5,0.5,0.5,0.5);
30
31   // Repeat a 1 - x^2 (0 < x < 1) curve and roll it with sinus.
32   float dst = frac(pos.y * distortionFreq + distortionRoll * sin_time_0_X);
33   dst *= (1 - dst);
34   // Make sure distortion is highest in the center of the image
35   dst /= 1 + distortionScale * abs(pos.y);
36
37   // ... and finally distort
38   img.x += distortionScale * noisy.x * dst;
39   float4 image = tex2D(Image, img);
40
41   // Combine frame, distorted image and interference
42   return frame * (interference * rand.x + image);
43}
44
Note: See TracBrowser for help on using the repository browser.