[Bf-blender-cvs] [bbe1b54] master: Fix T43689, viewport compositing does not respect alpha settings for background.

Antony Riakiotakis noreply at git.blender.org
Mon Feb 16 14:42:44 CET 2015


Commit: bbe1b54818d7bb349ddf63efbcb18347a78cf714
Author: Antony Riakiotakis
Date:   Mon Feb 16 14:42:36 2015 +0100
Branches: master
https://developer.blender.org/rBbbe1b54818d7bb349ddf63efbcb18347a78cf714

Fix T43689, viewport compositing does not respect alpha settings for
background.

For SSAO supporting this is no problem, for DOF we would ideally do
blurred alpha, but alpha channel in blurred buffers is occupied by coc
field, so use original color alpha instead. It's not entirely correct
but it's better than nothing.

===================================================================

M	source/blender/gpu/intern/gpu_compositing.c
M	source/blender/gpu/shaders/gpu_shader_fx_dof_frag.glsl
M	source/blender/gpu/shaders/gpu_shader_fx_ssao_frag.glsl

===================================================================

diff --git a/source/blender/gpu/intern/gpu_compositing.c b/source/blender/gpu/intern/gpu_compositing.c
index b423c14..cf28807 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 d52ab22..e9dab04 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 b33fda9..86e10af 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);
 }




More information about the Bf-blender-cvs mailing list