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.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user