Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/lod/materials/programs/OldTV.cg @ 11639

Last change on this file since 11639 was 5312, checked in by landauf, 16 years ago

added shaders (compositors, materials, cg programs and textures)

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
1
2
3sampler Image: register(s0);
4sampler Rand: register(s1);
5sampler Noise: register(s2);
6
7float4 OldTV_ps(float2 pos: TEXCOORD1, float2 img: TEXCOORD0,
8    uniform float distortionFreq: register(c3),
9    uniform float distortionScale: register(c4),
10    uniform float distortionRoll: register(c5),
11    uniform float interference: register(c7),
12    uniform float frameLimit: register(c8),
13    uniform float frameShape: register(c0),
14    uniform float frameSharpness: register(c1),
15    uniform float time_0_X: register(c2),
16    uniform float sin_time_0_X: register(c6)
17
18) : COLOR {
19   // Define a frame shape
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   float rand = tex3D(Rand, float3(1.5 * pos, time_0_X)) - 0.2;
25
26   // Some signed noise for the distortion effect
27   float noisy = tex3D(Noise, float3(0, 0.5 * pos.y, 0.1 * time_0_X)) - 0.5;
28
29   // Repeat a 1 - x^2 (0 < x < 1) curve and roll it with sinus.
30   float dst = frac(pos.y * distortionFreq + distortionRoll * sin_time_0_X);
31   dst *= (1 - dst);
32   // Make sure distortion is highest in the center of the image
33   dst /= 1 + distortionScale * abs(pos.y);
34
35   // ... and finally distort
36   img.x += distortionScale * noisy * dst;
37   float4 image = tex2D(Image, img);
38
39   // Combine frame, distorted image and interference
40   return frame * (interference * rand + image);
41}
42
Note: See TracBrowser for help on using the repository browser.