diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-09-07 20:16:33 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-09-07 20:16:33 -0300 |
commit | c023a132d0a1ed0979aa94985257cf0568f44508 (patch) | |
tree | 33b506390c4929e19c1b97819dea9978595591a2 /drivers/gles3/shaders/effect_blur.glsl | |
parent | eedb39091aaa1dc0b8f204844bb1eb270b2349f6 (diff) |
Fixed orthogonal projection in all effects and post processes
Diffstat (limited to 'drivers/gles3/shaders/effect_blur.glsl')
-rw-r--r-- | drivers/gles3/shaders/effect_blur.glsl | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/gles3/shaders/effect_blur.glsl b/drivers/gles3/shaders/effect_blur.glsl index 09e522866c..b5f98a1244 100644 --- a/drivers/gles3/shaders/effect_blur.glsl +++ b/drivers/gles3/shaders/effect_blur.glsl @@ -168,7 +168,11 @@ void main() { float depth = textureLod( dof_source_depth, uv_interp, 0.0).r; depth = depth * 2.0 - 1.0; +#ifdef USE_ORTHOGONAL_PROJECTION + depth = ((depth + (camera_z_far + camera_z_near)/(camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near))/2.0; +#else depth = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - depth * (camera_z_far - camera_z_near)); +#endif float amount = smoothstep(dof_begin,dof_end,depth); float k_accum=0.0; @@ -182,8 +186,11 @@ void main() { float tap_depth = texture( dof_source_depth, tap_uv, 0.0).r; tap_depth = tap_depth * 2.0 - 1.0; +#ifdef USE_ORTHOGONAL_PROJECTION + tap_depth = ((tap_depth + (camera_z_far + camera_z_near)/(camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near))/2.0; +#else tap_depth = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - tap_depth * (camera_z_far - camera_z_near)); - +#endif float tap_amount = mix(smoothstep(dof_begin,dof_end,tap_depth),1.0,int_ofs==0); tap_amount*=tap_amount*tap_amount; //prevent undesired glow effect @@ -221,7 +228,11 @@ void main() { float tap_depth = texture( dof_source_depth, tap_uv, 0.0).r; tap_depth = tap_depth * 2.0 - 1.0; +#ifdef USE_ORTHOGONAL_PROJECTION + tap_depth = ((tap_depth + (camera_z_far + camera_z_near)/(camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near))/2.0; +#else tap_depth = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - tap_depth * (camera_z_far - camera_z_near)); +#endif float tap_amount = 1.0-smoothstep(dof_end,dof_begin,tap_depth); tap_amount*=tap_amount*tap_amount; //prevent undesired glow effect |