Replace texture2D by texture in dof.frag
This commit is contained in:
parent
1073335f4d
commit
0ccac5d316
@ -21,62 +21,58 @@ void main()
|
||||
|
||||
vec2 offset = 10. / screen;
|
||||
|
||||
vec4 col = texture2D(tex, uv);
|
||||
vec4 col = texture(tex, uv);
|
||||
vec4 colOriginal = col;
|
||||
// Weight from here http://artmartinsh.blogspot.fr/2010/02/glsl-lens-blur-filter-with-bokeh.html
|
||||
|
||||
col += texture2D(tex, uv + (vec2(0.0, 0.4) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(0.15, 0.37) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(0.29,0.29) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(-0.37,0.15) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(0.4, 0.0) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(0.37, -0.15) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(0.29, -0.29) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(-0.15, -0.37) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(0.0, -0.4) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(-0.15, 0.37) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(-0.29, 0.29) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(0.37, 0.15) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(-0.4, 0.0) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(-0.37, -0.15) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(-0.29, -0.29) * offset) * blur);
|
||||
col += texture2D(tex, uv + (vec2(0.15, -0.37) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(0.0, 0.4) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(0.15, 0.37) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(0.29,0.29) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(-0.37,0.15) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(0.4, 0.0) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(0.37, -0.15) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(0.29, -0.29) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(-0.15, -0.37) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(0.0, -0.4) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(-0.15, 0.37) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(-0.29, 0.29) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(0.37, 0.15) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(-0.4, 0.0) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(-0.37, -0.15) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(-0.29, -0.29) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(0.15, -0.37) * offset) * blur);
|
||||
|
||||
col += texture2D(tex, uv + (vec2(0.15, 0.37) * offset) * blur * 0.9);
|
||||
col += texture2D(tex, uv + (vec2(-0.37, 0.15) * offset) * blur * 0.9);
|
||||
col += texture2D(tex, uv + (vec2(0.37, -0.15) * offset) * blur * 0.9);
|
||||
col += texture2D(tex, uv + (vec2(-0.15, -0.37) * offset) * blur * 0.9);
|
||||
col += texture2D(tex, uv + (vec2(-0.15, 0.37) * offset) * blur * 0.9);
|
||||
col += texture2D(tex, uv + (vec2(0.37, 0.15) * offset) * blur * 0.9);
|
||||
col += texture2D(tex, uv + (vec2(-0.37, -0.15) * offset) * blur * 0.9);
|
||||
col += texture2D(tex, uv + (vec2(0.15, -0.37) * offset) * blur * 0.9);
|
||||
col += texture(tex, uv + (vec2(0.15, 0.37) * offset) * blur * 0.9);
|
||||
col += texture(tex, uv + (vec2(-0.37, 0.15) * offset) * blur * 0.9);
|
||||
col += texture(tex, uv + (vec2(0.37, -0.15) * offset) * blur * 0.9);
|
||||
col += texture(tex, uv + (vec2(-0.15, -0.37) * offset) * blur * 0.9);
|
||||
col += texture(tex, uv + (vec2(-0.15, 0.37) * offset) * blur * 0.9);
|
||||
col += texture(tex, uv + (vec2(0.37, 0.15) * offset) * blur * 0.9);
|
||||
col += texture(tex, uv + (vec2(-0.37, -0.15) * offset) * blur * 0.9);
|
||||
col += texture(tex, uv + (vec2(0.15, -0.37) * offset) * blur * 0.9);
|
||||
|
||||
col += texture2D(tex, uv + (vec2(0.29, 0.29) * offset) * blur * 0.7);
|
||||
col += texture2D(tex, uv + (vec2(0.4, 0.0) * offset) * blur * 0.7);
|
||||
col += texture2D(tex, uv + (vec2(0.29, -0.29) * offset) * blur * 0.7);
|
||||
col += texture2D(tex, uv + (vec2(0.0, -0.4) * offset) * blur * 0.7);
|
||||
col += texture2D(tex, uv + (vec2(-0.29, 0.29) * offset) * blur * 0.7);
|
||||
col += texture2D(tex, uv + (vec2(-0.4, 0.0) * offset) * blur * 0.7);
|
||||
col += texture2D(tex, uv + (vec2(-0.29, -0.29) * offset) * blur * 0.7);
|
||||
col += texture2D(tex, uv + (vec2(0.0, 0.4) * offset) * blur *0.7);
|
||||
col += texture(tex, uv + (vec2(0.29, 0.29) * offset) * blur * 0.7);
|
||||
col += texture(tex, uv + (vec2(0.4, 0.0) * offset) * blur * 0.7);
|
||||
col += texture(tex, uv + (vec2(0.29, -0.29) * offset) * blur * 0.7);
|
||||
col += texture(tex, uv + (vec2(0.0, -0.4) * offset) * blur * 0.7);
|
||||
col += texture(tex, uv + (vec2(-0.29, 0.29) * offset) * blur * 0.7);
|
||||
col += texture(tex, uv + (vec2(-0.4, 0.0) * offset) * blur * 0.7);
|
||||
col += texture(tex, uv + (vec2(-0.29, -0.29) * offset) * blur * 0.7);
|
||||
col += texture(tex, uv + (vec2(0.0, 0.4) * offset) * blur *0.7);
|
||||
|
||||
col += texture2D(tex, uv + (vec2(0.29, 0.29) * offset) * blur * 0.4);
|
||||
col += texture2D(tex, uv + (vec2(0.4, 0.0) * offset) * blur * 0.4);
|
||||
col += texture2D(tex, uv + (vec2(0.29, -0.29) * offset) * blur * 0.4);
|
||||
col += texture2D(tex, uv + (vec2(0.0, -0.4) * offset) * blur * 0.4);
|
||||
col += texture2D(tex, uv + (vec2(-0.29, 0.29) * offset) * blur * 0.4);
|
||||
col += texture2D(tex, uv + (vec2(-0.4, 0.0) * offset) * blur * 0.4);
|
||||
col += texture2D(tex, uv + (vec2(-0.29, -0.29) * offset) * blur * 0.4);
|
||||
col += texture2D(tex, uv + (vec2(0.0, 0.4) * offset) * blur * 0.4);
|
||||
col += texture(tex, uv + (vec2(0.29, 0.29) * offset) * blur * 0.4);
|
||||
col += texture(tex, uv + (vec2(0.4, 0.0) * offset) * blur * 0.4);
|
||||
col += texture(tex, uv + (vec2(0.29, -0.29) * offset) * blur * 0.4);
|
||||
col += texture(tex, uv + (vec2(0.0, -0.4) * offset) * blur * 0.4);
|
||||
col += texture(tex, uv + (vec2(-0.29, 0.29) * offset) * blur * 0.4);
|
||||
col += texture(tex, uv + (vec2(-0.4, 0.0) * offset) * blur * 0.4);
|
||||
col += texture(tex, uv + (vec2(-0.29, -0.29) * offset) * blur * 0.4);
|
||||
col += texture(tex, uv + (vec2(0.0, 0.4) * offset) * blur * 0.4);
|
||||
|
||||
col = vec4(col.rgb / 41.0, col.a);
|
||||
depth = clamp((FragPos.z/280), 0., 1.);
|
||||
depth = (1 - depth);
|
||||
vec3 final = colOriginal.rgb * depth + col.rgb * (1 - depth);
|
||||
|
||||
/*
|
||||
FragColor.xyz = vec3(depth);
|
||||
FragColor.a = 1.0;
|
||||
*/
|
||||
FragColor = vec4(final, 1.);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user