LookDev: Use theme background instead of world color
authorClément Foucault <foucault.clem@gmail.com>
Tue, 18 Sep 2018 20:18:49 +0000 (22:18 +0200)
committerClément Foucault <foucault.clem@gmail.com>
Tue, 18 Sep 2018 20:18:49 +0000 (22:18 +0200)
This is much less confusing than relying on an hidden parameter (the world
color) that you can only see if you disable the world node tree.

source/blender/draw/engines/eevee/eevee_lookdev.c

index 5c12eac4ac14870e282b60e622c2f0885f82dd94..49cf468711e5f9105cb24b1f996fbf17012b0acf 100644 (file)
 
 #include "ED_screen.h"
 
+#include "UI_resources.h"
+
 #include "eevee_private.h"
 #include "eevee_lightcache.h"
 
+#include "draw_common.h"
+
 static void eevee_lookdev_lightcache_delete(EEVEE_Data *vedata)
 {
        EEVEE_StorageList *stl = vedata->stl;
@@ -51,7 +55,7 @@ static void eevee_lookdev_lightcache_delete(EEVEE_Data *vedata)
 
 void EEVEE_lookdev_cache_init(
         EEVEE_Data *vedata, DRWShadingGroup **grp, GPUShader *shader, DRWPass *pass,
-        World *world, EEVEE_LightProbesInfo *pinfo)
+        World *UNUSED(world), EEVEE_LightProbesInfo *pinfo)
 {
        EEVEE_StorageList *stl = vedata->stl;
        EEVEE_TextureList *txl = vedata->txl;
@@ -103,17 +107,17 @@ void EEVEE_lookdev_cache_init(
 
                        stl->g_data->light_cache = stl->lookdev_lightcache;
 
+                       static float background_color[4];
+                       UI_GetThemeColor4fv(TH_HIGH_GRAD, background_color);
+                       /* XXX: Really quick conversion to avoid washed out background.
+                        * Needs to be addressed properly (color managed using ocio). */
+                       srgb_to_linearrgb_v4(background_color, background_color);
+
                        *grp = DRW_shgroup_create(shader, pass);
                        axis_angle_to_mat3_single(stl->g_data->studiolight_matrix, 'Z', v3d->shading.studiolight_rot_z);
                        DRW_shgroup_uniform_mat3(*grp, "StudioLightMatrix", stl->g_data->studiolight_matrix);
-
-                       if (world) {
-                               DRW_shgroup_uniform_vec3(*grp, "color", &world->horr, 1);
-                       } else {
-                               static float col[4] = {0.0f};
-                               DRW_shgroup_uniform_vec3(*grp, "color", col, 1);
-                       }
                        DRW_shgroup_uniform_float(*grp, "backgroundAlpha", &stl->g_data->background_alpha, 1);
+                       DRW_shgroup_uniform_vec3(*grp, "color", background_color, 1);
                        DRW_shgroup_call_add(*grp, geom, NULL);
                        if (!pinfo) {
                                /* Do not fadeout when doing probe rendering, only when drawing the background */