Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. uniform sampler2D Render;
  2. uniform sampler2D Tex0;
  3. uniform sampler2D Tex1;
  4.  
  5. uniform vec2 PixelSize;
  6.  
  7. float Distance = 10.0;
  8. float Range = 5.0;
  9. float Far = 2450.0;
  10.  
  11. void main() {
  12. vec2 uv = gl_TexCoord[0].xy;
  13. Distance = texture2D(Tex1, vec2(0.5, 0.5)).x;
  14. float currentDepth = texture2D(Tex1, uv).x;
  15. vec3 color = texture2D(Tex0, uv).rgb;
  16. vec3 colorBlur = texture2D(Render, uv).rgb;
  17. float depthLin = currentDepth;
  18. float blur = 0.0;
  19. float nearBoundDOF = clamp((Distance - 20.0/Far),0.0,Distance);
  20. float farBoundDOF = clamp((Distance + 20.0/Far),Distance,1.0);
  21. if (depthLin > farBoundDOF)
  22. blur = clamp(((depthLin - farBoundDOF)/farBoundDOF),0.0,1.0);
  23. else if (depthLin < nearBoundDOF)
  24. blur = (nearBoundDOF - depthLin)/nearBoundDOF;
  25. gl_FragData[0].rgba = vec4(mix(color, colorBlur, blur), 1.0);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement