Workbench: Support transparency from object color alpha
authorClément Foucault <foucault.clem@gmail.com>
Tue, 29 Jan 2019 18:56:22 +0000 (19:56 +0100)
committerClément Foucault <foucault.clem@gmail.com>
Tue, 29 Jan 2019 19:34:11 +0000 (20:34 +0100)
Support the alpha channel use of the object color in solid mode.

The Transparency effect is still using the Xray algorithm and not
true Alpha blending.

source/blender/draw/engines/workbench/workbench_deferred.c
source/blender/draw/engines/workbench/workbench_private.h

index c1b4398c3d254cdad8460063b23dc558925a2bb1..3f8a29a20a5b807e6cccbe4e4bcfc7f585202178 100644 (file)
@@ -938,8 +938,17 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
                else if (ELEM(wpd->shading.color_type,
                              V3D_SHADING_SINGLE_COLOR, V3D_SHADING_OBJECT_COLOR, V3D_SHADING_RANDOM_COLOR))
                {
-                       /* Draw solid color */
-                       material = get_or_create_material_data(vedata, ob, NULL, NULL, wpd->shading.color_type, 0);
+                       if ((ob->col[3] < 1.0f) &&
+                           (wpd->shading.color_type == V3D_SHADING_OBJECT_COLOR))
+                       {
+                               wpd->shading.xray_alpha = ob->col[3];
+                               material = workbench_forward_get_or_create_material_data(vedata, ob, NULL, NULL, wpd->shading.color_type, 0);
+                               has_transp_mat = true;
+                       }
+                       else {
+                               /* Draw solid color */
+                               material = get_or_create_material_data(vedata, ob, NULL, NULL, wpd->shading.color_type, 0);
+                       }
                        if (is_sculpt_mode) {
                                DRW_shgroup_call_sculpt_add(material->shgrp, ob, ob->obmat);
                        }
index e9c98b020acce34f966f82f5f8b660ee7c16de21..ee0811eecfe9085f57573d40da332fcad9575f92 100644 (file)
@@ -62,7 +62,7 @@
 #define SHADOW_ENABLED(wpd) (wpd->shading.flag & V3D_SHADING_SHADOW)
 #define GHOST_ENABLED(psl) (!DRW_pass_is_empty(psl->ghost_prepass_pass) || !DRW_pass_is_empty(psl->ghost_prepass_hair_pass))
 #define CULL_BACKFACE_ENABLED(wpd) ((wpd->shading.flag & V3D_SHADING_BACKFACE_CULLING) != 0)
-#define OIT_ENABLED(wpd) (wpd->shading.color_type == V3D_SHADING_MATERIAL_COLOR)
+#define OIT_ENABLED(wpd) (ELEM(wpd->shading.color_type, V3D_SHADING_MATERIAL_COLOR, V3D_SHADING_OBJECT_COLOR))
 
 #define IS_NAVIGATING(wpd) ((DRW_context_state_get()->rv3d) && (DRW_context_state_get()->rv3d->rflag & RV3D_NAVIGATING))
 #define FXAA_ENABLED(wpd) ((!DRW_state_is_opengl_render()) && \