diff --git a/source/blender/gpu/intern/gpu_compositing.c b/source/blender/gpu/intern/gpu_compositing.c index b423c14bd4b..cf288070126 100644 --- a/source/blender/gpu/intern/gpu_compositing.c +++ b/source/blender/gpu/intern/gpu_compositing.c @@ -257,7 +257,7 @@ bool GPU_fx_compositor_initialize_passes( GPUFX *fx, const rcti *rect, const rcti *scissor_rect, const GPUFXSettings *fx_settings) { - int w = BLI_rcti_size_x(rect) + 1, h = BLI_rcti_size_y(rect) + 1; + int w = BLI_rcti_size_x(rect), h = BLI_rcti_size_y(rect); char err_out[256]; int num_passes = 0; char fx_flag = fx_settings->fx_flag; @@ -282,6 +282,12 @@ bool GPU_fx_compositor_initialize_passes( return false; } + /* scissor is missing when drawing offscreen, in that case, dimensions match exactly. In opposite case + * add one to match viewport dimensions */ + if (!scissor_rect) { + w++, h++; + } + fx->num_passes = 0; /* dof really needs a ping-pong buffer to work */ if (fx_flag & GPU_FX_FLAG_DOF) diff --git a/source/blender/gpu/shaders/gpu_shader_fx_dof_frag.glsl b/source/blender/gpu/shaders/gpu_shader_fx_dof_frag.glsl index d52ab2243fe..e9dab04de5d 100644 --- a/source/blender/gpu/shaders/gpu_shader_fx_dof_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_fx_dof_frag.glsl @@ -186,7 +186,9 @@ void fifth_pass() vec4 color = factors.x * color_orig + factors.y * smallblurred + factors.z * mediumblurred + factors.w * highblurred; color /= dot(factors, vec4(1.0)); - gl_FragColor = vec4(color.rgb, 1.0); + /* using original color is not correct, but use that for now because alpha of + * blurred buffers uses CoC instead */ + gl_FragColor = vec4(color.rgb, color_orig.a); } diff --git a/source/blender/gpu/shaders/gpu_shader_fx_ssao_frag.glsl b/source/blender/gpu/shaders/gpu_shader_fx_ssao_frag.glsl index b33fda92a46..86e10af8c0d 100644 --- a/source/blender/gpu/shaders/gpu_shader_fx_ssao_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_fx_ssao_frag.glsl @@ -77,6 +77,7 @@ float calculate_ssao_factor(float depth) void main() { float depth = texture2D(depthbuffer, uvcoordsvar.xy).r; - vec4 color = mix(texture2D(colorbuffer, uvcoordsvar.xy), ssao_color, calculate_ssao_factor(depth)); - gl_FragColor = vec4(color.rgb, 1.0); + vec4 scene_col = texture2D(colorbuffer, uvcoordsvar.xy); + vec3 final_color = mix(scene_col.rgb, ssao_color.rgb, calculate_ssao_factor(depth)); + gl_FragColor = vec4(final_color.rgb, scene_col.a); }