File: fft_fragment_program_resolve.glsl.frag.h

package info (click to toggle)
retroarch 1.7.3%2Bdfsg1-1.1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 49,188 kB
  • sloc: ansic: 600,492; cpp: 23,670; objc: 8,299; asm: 6,404; sh: 2,203; xml: 2,144; makefile: 1,867; python: 1,582; java: 941; perl: 393
file content (30 lines) | stat: -rw-r--r-- 781 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "shaders_common.h"

static const char *fft_fragment_program_resolve = GLSL_300(
   precision mediump float;
   precision highp int;
   precision highp usampler2D;
   precision highp isampler2D;
   in vec2 vTex;
   out vec4 FragColor;
   uniform usampler2D sFFT;

   vec4 get_heights(highp uvec2 h) {
     vec2 l = unpackHalf2x16(h.x);
     vec2 r = unpackHalf2x16(h.y);
     vec2 channels[4] = vec2[4](
        l, 0.5 * (l + r), r, 0.5 * (l - r));
     vec4 amps;
     for (int i = 0; i < 4; i++)
        amps[i] = dot(channels[i], channels[i]);

     return 9.0 * log(amps + 0.0001) - 22.0;
   }

   void main() {
      uvec2 h = textureLod(sFFT, vTex, 0.0).rg;
      vec4 height = get_heights(h);
      height = (height + 40.0) / 80.0;
      FragColor = height;
   }
);