[12115] | 1 | #version 150 |
---|
| 2 | |
---|
| 3 | in vec4 pos; |
---|
| 4 | in vec2 oUv0; |
---|
| 5 | out vec4 fragColour; |
---|
| 6 | |
---|
| 7 | uniform sampler2D Image; |
---|
| 8 | uniform sampler3D Rand; |
---|
| 9 | uniform sampler3D Noise; |
---|
| 10 | uniform float distortionFreq; |
---|
| 11 | uniform float distortionScale; |
---|
| 12 | uniform float distortionRoll; |
---|
| 13 | uniform float interference; |
---|
| 14 | uniform float frameLimit; |
---|
| 15 | uniform float frameShape; |
---|
| 16 | uniform float frameSharpness; |
---|
| 17 | uniform float time_0_X; |
---|
| 18 | uniform float sin_time_0_X; |
---|
| 19 | |
---|
| 20 | void 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 | } |
---|