SHARE
TWEET

Untitled

a guest Dec 26th, 2014 166 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #version 400
  2.  
  3. in vec2 coord;
  4.  
  5. uniform sampler2D depthMap;
  6. uniform vec2 screenSize;
  7. uniform mat4 projection;
  8. uniform vec2 blurDir;
  9.  
  10. void main() {
  11.         float depth = texture(depthMap, coord).x;
  12.        
  13.         float sum = 0.0f;
  14.         float wsum = 0.0f;
  15.        
  16.         float filterRadius = 10;
  17.         float blurScale = .1;
  18.         float blurDepthFalloff = 1000;
  19.        
  20.         for (float x = -filterRadius; x <= filterRadius; x += 1.0f) {
  21.                 float s = texture(depthMap, coord + x*blurDir).x;
  22.                
  23.                 float r = x * blurScale;
  24.                 float w = exp(-r*r);
  25.                
  26.                 float r2 = (s - depth) * blurDepthFalloff;
  27.                 float g = exp(-r2*r2);
  28.                
  29.                 sum += s * w * g;
  30.                 wsum += w * g;
  31.         }
  32.  
  33.         if (wsum > 0.0f) {
  34.                 sum /= wsum;
  35.         }
  36.        
  37.         gl_FragDepth = sum;
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top