Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/Example/GLSL150/OldTV.glsl @ 12092

Last change on this file since 12092 was 12091, checked in by wiesep, 6 years ago

Updated programs and adjusted Material to work with GLSL>150

File size: 1.3 KB
Line 
1#version 150
2
3in vec4 pos;
4in vec2 oUv0;
5out vec4 fragColour;
6
7uniform sampler2D Image;
8uniform sampler3D Rand;
9uniform sampler3D Noise;
10uniform float distortionFreq;
11uniform float distortionScale;
12uniform float distortionRoll;
13uniform float interference;
14uniform float frameLimit;
15uniform float frameShape;
16uniform float frameSharpness;
17uniform float time_0_X;
18uniform float sin_time_0_X;
19
20void main()
21{
22    // Define a frame shape
23    float f = (1 - pos.x * pos.x) * (1 - pos.y * pos.y);
24    float frame = clamp(frameSharpness * (pow(f, frameShape) - frameLimit), 0.0, 1.0);
25
26    // Interference ... just a texture filled with rand()
27    float rand = texture(Rand, vec3(1.5 * pos.x, 1.5 * pos.y, time_0_X)).x - 0.2;
28
29    // Some signed noise for the distortion effect
30    float noisy = texture(Noise, vec3(0, 0.5 * pos.y, 0.1 * time_0_X)).x - 0.5;
31
32    // Repeat a 1 - x^2 (0 < x < 1) curve and roll it with sinus.
33    float dst = fract(pos.y * distortionFreq + distortionRoll * sin_time_0_X);
34    dst *= (1 - dst);
35    // Make sure distortion is highest in the center of the image
36    dst /= 1 + distortionScale * abs(pos.y);
37
38    // ... and finally distort
39    vec2 inUv = oUv0;
40    inUv.x += distortionScale * noisy * dst;
41    vec4 image = texture(Image, inUv);
42
43    // Combine frame, distorted image and interference
44    fragColour = frame * (interference * rand + image);
45}
Note: See TracBrowser for help on using the repository browser.