6uniform sampler2D source_tex;
 
    7uniform sampler2D depth_tex;
 
    9uniform 
float blur_width;
 
   12const float PI = 3.14159265;
 
   13const float threshold = 0.005;
 
   16uniform 
vec2 source_tex_size;
 
   17#define width float(source_tex_size.x); 
   18#define height float(source_tex_size.y); 
   20float width  = float(textureSize(source_tex,0).x);
 
   21float height = float(textureSize(source_tex,0).y);
 
   25float gaussian(in 
float x, in 
float s) {
 
   26    return exp(-x * x / (2.0 * s * s)) / (s * sqrt(2.0 * PI));
 
   29float get_z_coeff(in vec2 pos) {
 
   30    float zCoef = glup_texture(depth_tex, pos).r;
 
   31    zCoef = 3.0 * (zCoef - 0.1) ;
 
   35float get_z_dist(in vec2 center_pos, in vec2 other_pos) {
 
   36    return abs(get_z_coeff(center_pos) - get_z_coeff(other_pos));
 
   40    int n = int(floor(3.0 * blur_width) - 1.0);
 
   50    for(
int i = -5; i <= 5; i++) {
 
   52        for(
int i = -n; i <= n; i++) {
 
   54            float x_offset, y_offset;
 
   63            x_offset = x_offset / width;
 
   64            y_offset = y_offset / height;
 
   66            cur_pix_coords = 
vec2(x_offset, y_offset) + tex_coord;
 
   68            if(get_z_dist(tex_coord, cur_pix_coords) <= threshold) {
 
   69                float weight = gaussian(
float(i), blur_width);
 
   76        for(
int i = -5; i <= 5; i++) {
 
   78            for(
int i = -n; i <= n; i++) {
 
   80                float x_offset, y_offset;
 
   89                x_offset = x_offset / width;
 
   90                y_offset = y_offset / height;
 
   92                cur_pix_coords = 
vec2(x_offset, y_offset) + tex_coord;
 
   94                if(get_z_dist(tex_coord, cur_pix_coords) <= threshold) {
 
   95                    cur_pix_tex = glup_texture(source_tex, cur_pix_coords);
 
   96                    float weight = gaussian(
float(i), blur_width) / sum;
 
   97                    final_pix_tex += cur_pix_tex * weight;
 
  100            glup_FragColor.rgb = final_pix_tex.rgb;
 
vecng< 4, Numeric::float64 > vec4
Represents points and vectors in 4d.
vecng< 2, Numeric::float64 > vec2
Represents points and vectors in 2d.