Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uniform sampler2D Render;
- uniform sampler2D Tex0;
- uniform sampler2D Tex1;
- uniform vec2 PixelSize;
- float Distance = 10.0;
- float Range = 5.0;
- float Far = 2450.0;
- void main() {
- vec2 uv = gl_TexCoord[0].xy;
- Distance = texture2D(Tex1, vec2(0.5, 0.5)).x;
- float currentDepth = texture2D(Tex1, uv).x;
- vec3 color = texture2D(Tex0, uv).rgb;
- vec3 colorBlur = texture2D(Render, uv).rgb;
- float depthLin = currentDepth;
- float blur = 0.0;
- float nearBoundDOF = clamp((Distance - 20.0/Far),0.0,Distance);
- float farBoundDOF = clamp((Distance + 20.0/Far),Distance,1.0);
- if (depthLin > farBoundDOF)
- blur = clamp(((depthLin - farBoundDOF)/farBoundDOF),0.0,1.0);
- else if (depthLin < nearBoundDOF)
- blur = (nearBoundDOF - depthLin)/nearBoundDOF;
- gl_FragData[0].rgba = vec4(mix(color, colorBlur, blur), 1.0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement