diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-02-13 03:24:40 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-02-13 03:24:40 +0300 |
commit | d051dd01eda2f893fa3d72a22da3e9bafee91bb1 (patch) | |
tree | bebfa5f59858f12a38fa67e538fb51c53094ce11 | |
parent | a40d9ce553554ab3cecac25fe3662ab3106f1b41 (diff) |
Workbench: Fix premultiply alpha issue in transparent material
-rw-r--r-- | source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl | 3 | ||||
-rw-r--r-- | source/blender/draw/engines/workbench/workbench_deferred.c | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl index 91e1ebabae4..0a4d64b37ad 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_forward_composite_frag.glsl @@ -25,7 +25,8 @@ void main() vec3 trans_color = trans_accum.rgb / clamp(trans_accum.a, 1e-4, 5e4); - fragColor = vec4(trans_color, 1.0 - trans_revealage); + fragColor.a = 1.0 - trans_revealage; + fragColor.rgb = trans_color * fragColor.a; #ifdef V3D_SHADING_OBJECT_OUTLINE uint object_id = texelFetch(objectId, texel, 0).r; diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index dfeb50248df..762eeced176 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -827,7 +827,7 @@ void workbench_deferred_cache_init(WORKBENCH_Data *vedata) } /* OIT Composite */ { - int state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA; + int state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA_PREMUL; psl->oit_composite_pass = DRW_pass_create("OIT Composite", state); grp = DRW_shgroup_create(e_data.oit_resolve_sh, psl->oit_composite_pass); |