Color management: change view transform for color pickers and display modes.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Fri, 1 Feb 2019 19:30:10 +0000 (20:30 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Fri, 1 Feb 2019 19:56:42 +0000 (20:56 +0100)
* Use simple default view transform for color pickers, as Filmic does not work
  well for all types of colors. We better handle this with an option and tagging
  of colors as emissive or albedo like.
* For solid/workbench we also no longer use Filmic, as there is not enough contrast
  and it's not really needed since this is not physically based lighting.
* For lookdev always take into account the view transform and look. Other view
  settings like exposure are only taken into account if scene lighting is used,
  since these are often dependent on scene light intensity.

Fixes T61022, T57649, T59363.

14 files changed:
release/datafiles/colormanagement/config.ocio
source/blender/blenkernel/BKE_colortools.h
source/blender/blenkernel/intern/colortools.c
source/blender/blenkernel/intern/scene.c
source/blender/blenloader/intern/versioning_defaults.c
source/blender/draw/engines/eevee/eevee_engine.c
source/blender/draw/engines/eevee/eevee_private.h
source/blender/draw/engines/workbench/workbench_data.c
source/blender/draw/engines/workbench/workbench_effect_aa.c
source/blender/draw/engines/workbench/workbench_private.h
source/blender/draw/intern/DRW_render.h
source/blender/draw/intern/draw_manager.c
source/blender/imbuf/IMB_colormanagement.h
source/blender/imbuf/intern/colormanagement.c

index 411af8ebdf26583a217ad3cb9f99c5305828713a..e9663382b04039f88c957a3f2f2ab4f9b4388598 100644 (file)
@@ -70,7 +70,7 @@ displays:
     - !<View> {name: Default, colorspace: Raw}
 
 active_displays: [sRGB, DCIP3, Rec709, XYZ, None]
-active_views: [Filmic, Default, RRT, Raw, Log]
+active_views: [Default, Filmic, RRT, Raw, Log]
 
 colorspaces:
   - !<ColorSpace>
index 49508fee05c3decdb8e878530676695d12456d3b..15015eb85e05325accec2d353aeda5119af0f165 100644 (file)
@@ -94,10 +94,12 @@ void BKE_color_managed_display_settings_copy(
         const struct ColorManagedDisplaySettings *settings);
 
 /* Initialize view settings to be best suitable for render type of viewing.
- * This will use default view transform from the OCIO configuration. */
+ * This will use default view transform from the OCIO configuration if none
+ * is specified. */
 void BKE_color_managed_view_settings_init_render(
         struct ColorManagedViewSettings *settings,
-        const struct ColorManagedDisplaySettings *display_settings);
+        const struct ColorManagedDisplaySettings *display_settings,
+        const char *view_transform);
 
 /* Initialize view settings which are best suitable for viewing non-render
  * images. For example,s movie clips while tracking. */
index 8f05634322acf3260e2aab381e9ea637dab48236..487468b1c611ef0bcb3777e7310b70f8248102af 100644 (file)
@@ -1574,23 +1574,28 @@ void BKE_color_managed_display_settings_copy(ColorManagedDisplaySettings *new_se
 
 void BKE_color_managed_view_settings_init_render(
         ColorManagedViewSettings *view_settings,
-        const ColorManagedDisplaySettings *display_settings)
+        const ColorManagedDisplaySettings *display_settings,
+        const char *view_transform)
 {
        struct ColorManagedDisplay *display =
                IMB_colormanagement_display_get_named(
                        display_settings->display_device);
-       BLI_strncpy(
-               view_settings->view_transform,
-               IMB_colormanagement_display_get_default_view_transform_name(display),
-               sizeof(view_settings->view_transform));
+
+       if (!view_transform) {
+               view_transform = IMB_colormanagement_display_get_default_view_transform_name(display);
+       }
+
        /* TODO(sergey): Find a way to make look query more reliable with non
         * default configuration. */
-       BLI_strncpy(view_settings->look, "None", sizeof(view_settings->look));
+       STRNCPY(view_settings->view_transform, view_transform);
+       STRNCPY(view_settings->look, "None");
 
        view_settings->flag = 0;
        view_settings->gamma = 1.0f;
        view_settings->exposure = 0.0f;
        view_settings->curve_mapping = NULL;
+
+       IMB_colormanagement_validate_settings(display_settings, view_settings);
 }
 
 void BKE_color_managed_view_settings_init_default(
index 618b2f94812be94eeea6799458d2a8b26fb6edb9..9c7a911e4786802601da055543b661fd2ce3e31d 100644 (file)
@@ -773,7 +773,8 @@ void BKE_scene_init(Scene *sce)
 
        BKE_color_managed_display_settings_init(&sce->display_settings);
        BKE_color_managed_view_settings_init_render(&sce->view_settings,
-                                                   &sce->display_settings);
+                                                   &sce->display_settings,
+                                                   "Filmic");
        BLI_strncpy(sce->sequencer_colorspace_settings.name, colorspace_name,
                    sizeof(sce->sequencer_colorspace_settings.name));
 
index 22c58c9e479e0e90f7316f59cb53b37e89d76a59..bfb236b0167f5480e866b06f28e47d79ca6b7e26 100644 (file)
@@ -301,6 +301,7 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
                        if (app_template && STREQ(app_template, "Video_Editing")) {
                                /* Filmic is too slow, use default until it is optimized. */
                                STRNCPY(scene->view_settings.view_transform, "Default");
+                               STRNCPY(scene->view_settings.look, "None");
                        }
                        else {
                                /* AV Sync break physics sim caching, disable until that is fixed. */
index cea89f531ac27ee7166e9cf0cfb2424abea2d757..6120a036deb6d51ab0529288984c06e76e8657f3 100644 (file)
@@ -53,7 +53,7 @@ static void eevee_engine_init(void *ved)
                /* Alloc transient pointers */
                stl->g_data = MEM_callocN(sizeof(*stl->g_data), __func__);
        }
-       stl->g_data->use_color_view_settings = USE_SCENE_LIGHT(v3d) || !LOOK_DEV_STUDIO_LIGHT_ENABLED(v3d);
+       stl->g_data->use_color_render_settings = USE_SCENE_LIGHT(v3d) || !LOOK_DEV_STUDIO_LIGHT_ENABLED(v3d);
        stl->g_data->background_alpha = DRW_state_draw_background() ? 1.0f : 0.0f;
        stl->g_data->valid_double_buffer = (txl->color_double_buffer != NULL);
        stl->g_data->valid_taa_history = (txl->taa_history != NULL);
@@ -308,39 +308,39 @@ static void eevee_draw_background(void *vedata)
 
 
        /* Tonemapping and transfer result to default framebuffer. */
-       bool use_view_settings = stl->g_data->use_color_view_settings;
+       bool use_render_settings = stl->g_data->use_color_render_settings;
 
        GPU_framebuffer_bind(dfbl->default_fb);
-       DRW_transform_to_display(stl->effects->final_tx, use_view_settings);
+       DRW_transform_to_display(stl->effects->final_tx, true, use_render_settings);
 
        /* Debug : Output buffer to view. */
        switch (G.debug_value) {
                case 1:
-                       if (txl->maxzbuffer) DRW_transform_to_display(txl->maxzbuffer, use_view_settings);
+                       if (txl->maxzbuffer) DRW_transform_to_display(txl->maxzbuffer, false, false);
                        break;
                case 2:
-                       if (effects->ssr_pdf_output) DRW_transform_to_display(effects->ssr_pdf_output, use_view_settings);
+                       if (effects->ssr_pdf_output) DRW_transform_to_display(effects->ssr_pdf_output, false, false);
                        break;
                case 3:
-                       if (effects->ssr_normal_input) DRW_transform_to_display(effects->ssr_normal_input, use_view_settings);
+                       if (effects->ssr_normal_input) DRW_transform_to_display(effects->ssr_normal_input, false, false);
                        break;
                case 4:
-                       if (effects->ssr_specrough_input) DRW_transform_to_display(effects->ssr_specrough_input, use_view_settings);
+                       if (effects->ssr_specrough_input) DRW_transform_to_display(effects->ssr_specrough_input, false, false);
                        break;
                case 5:
-                       if (txl->color_double_buffer) DRW_transform_to_display(txl->color_double_buffer, use_view_settings);
+                       if (txl->color_double_buffer) DRW_transform_to_display(txl->color_double_buffer, false, false);
                        break;
                case 6:
-                       if (effects->gtao_horizons_debug) DRW_transform_to_display(effects->gtao_horizons_debug, use_view_settings);
+                       if (effects->gtao_horizons_debug) DRW_transform_to_display(effects->gtao_horizons_debug, false, false);
                        break;
                case 7:
-                       if (effects->gtao_horizons) DRW_transform_to_display(effects->gtao_horizons, use_view_settings);
+                       if (effects->gtao_horizons) DRW_transform_to_display(effects->gtao_horizons, false, false);
                        break;
                case 8:
-                       if (effects->sss_data) DRW_transform_to_display(effects->sss_data, use_view_settings);
+                       if (effects->sss_data) DRW_transform_to_display(effects->sss_data, false, false);
                        break;
                case 9:
-                       if (effects->velocity_tx) DRW_transform_to_display(effects->velocity_tx, use_view_settings);
+                       if (effects->velocity_tx) DRW_transform_to_display(effects->velocity_tx, false, false);
                        break;
                default:
                        break;
index df107e55fff1f27cab5193e367d6ffff51dafaf1..d2e38f4a3ce4811b67441c9c7304f5b4e7a27a94 100644 (file)
@@ -815,7 +815,7 @@ typedef struct EEVEE_PrivateData {
        float mist_start, mist_inv_dist, mist_falloff;
 
        /* Color Management */
-       bool use_color_view_settings;
+       bool use_color_render_settings;
 } EEVEE_PrivateData; /* Transient data */
 
 /* eevee_data.c */
index d3fde2dd26a75ba73213c0c7100ff9003e985354..998b70831eaae36641497a8d4249e13448a5bd14 100644 (file)
@@ -42,17 +42,17 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd)
        View3D *v3d = draw_ctx->v3d;
        if (!v3d) {
                wpd->shading = scene->display.shading;
-               wpd->use_color_view_settings = true;
+               wpd->use_color_render_settings = true;
        }
        else if (v3d->shading.type == OB_RENDER &&
                 BKE_scene_uses_blender_workbench(scene))
        {
                wpd->shading = scene->display.shading;
-               wpd->use_color_view_settings = true;
+               wpd->use_color_render_settings = true;
        }
        else {
                wpd->shading = v3d->shading;
-               wpd->use_color_view_settings = false;
+               wpd->use_color_render_settings = false;
        }
 
        if (wpd->shading.light == V3D_LIGHTING_MATCAP) {
index 04907ea552383cbae1b794543bc78b0cfc995fa7..27bec676836f612fc0afdc254aa63b803dac7160 100644 (file)
@@ -61,7 +61,7 @@ static void workspace_aa_draw_transform(GPUTexture *tx, WORKBENCH_PrivateData *w
        }
        else {
                /* Display space result for viewport. */
-               DRW_transform_to_display(tx, wpd->use_color_view_settings);
+               DRW_transform_to_display(tx, wpd->use_color_render_settings, wpd->use_color_render_settings);
        }
 }
 
index d203932bec56134958ab4bcb5b26f71cf1c0ca54..2cd80d202f6661e8e2e29c62b652d08630698da4 100644 (file)
@@ -252,7 +252,7 @@ typedef struct WORKBENCH_PrivateData {
        bool dof_enabled;
 
        /* Color Management */
-       bool use_color_view_settings;
+       bool use_color_render_settings;
 } WORKBENCH_PrivateData; /* Transient data */
 
 typedef struct WORKBENCH_EffectInfo {
index e0fe0e9a14eac1b113d3c7cb7fb55d1dafed56e0..4740879928c2e03417060b1be595134783abea51 100644 (file)
@@ -232,7 +232,7 @@ void DRW_uniformbuffer_free(struct GPUUniformBuffer *ubo);
        } \
 } while (0)
 
-void DRW_transform_to_display(struct GPUTexture *tex, bool use_view_settings);
+void DRW_transform_to_display(struct GPUTexture *tex, bool use_view_transform, bool use_render_settings);
 void DRW_transform_none(struct GPUTexture *tex);
 void DRW_multisamples_resolve(
         struct GPUTexture *src_depth, struct GPUTexture *src_color, bool use_depth);
index 51490c5feb699b23f04bc13303e391faa4edbb8d..2daeccdd57268fac611fab2603b99af3cf67c6ee 100644 (file)
@@ -256,7 +256,7 @@ struct DupliObject *DRW_object_get_dupli(const Object *UNUSED(ob))
  * \{ */
 
 /* Use color management profile to draw texture to framebuffer */
-void DRW_transform_to_display(GPUTexture *tex, bool use_view_settings)
+void DRW_transform_to_display(GPUTexture *tex, bool use_view_transform, bool use_render_settings)
 {
        drw_state_set(DRW_STATE_WRITE_COLOR);
 
@@ -272,19 +272,26 @@ void DRW_transform_to_display(GPUTexture *tex, bool use_view_settings)
        if (!(DST.options.is_image_render && !DST.options.is_scene_render)) {
                Scene *scene = DST.draw_ctx.scene;
                ColorManagedDisplaySettings *display_settings = &scene->display_settings;
-               ColorManagedViewSettings *active_view_settings;
-               ColorManagedViewSettings default_view_settings;
-               if (use_view_settings) {
-                       active_view_settings = &scene->view_settings;
+               ColorManagedViewSettings view_settings;
+               if (use_render_settings) {
+                       /* Use full render settings, for renders with scene lighting. */
+                       view_settings = scene->view_settings;
+               }
+               else if (use_view_transform) {
+                       /* Use only view transform + look and nothing else for lookdev without
+                        * scene lighting, as exposure depends on scene light intensity. */
+                       BKE_color_managed_view_settings_init_render(&view_settings, display_settings, NULL);
+                       STRNCPY(view_settings.view_transform, scene->view_settings.view_transform);
+                       STRNCPY(view_settings.look, scene->view_settings.look);
                }
                else {
-                       BKE_color_managed_view_settings_init_render(
-                               &default_view_settings,
-                               display_settings);
-                       active_view_settings = &default_view_settings;
+                       /* For workbench use only default view transform in configuration,
+                        * using no scene settings. */
+                       BKE_color_managed_view_settings_init_render(&view_settings, display_settings, NULL);
                }
+
                use_ocio = IMB_colormanagement_setup_glsl_draw_from_space(
-                       active_view_settings, display_settings, NULL, dither, false);
+                       &view_settings, display_settings, NULL, dither, false);
        }
 
        if (!use_ocio) {
index e5d8fb7f27e0af4165700549c5f6889e19d5c62f..3d41352f9fe8f461892fbc8c8a8e1a19efc5afe0 100644 (file)
@@ -47,7 +47,7 @@ struct ColorSpace;
 
 void IMB_colormanagement_check_file_config(struct Main *bmain);
 
-void IMB_colormanagement_validate_settings(struct ColorManagedDisplaySettings *display_settings,
+void IMB_colormanagement_validate_settings(const struct ColorManagedDisplaySettings *display_settings,
                                            struct ColorManagedViewSettings *view_settings);
 
 const char *IMB_colormanagement_role_colorspace_name_get(int role);
index c2fb5e55bcbcd467999bddaa7fedbfc9782bbb4b..27bc28664d9ed1b2ec09825521c1f579ea65713f 100644 (file)
@@ -1168,7 +1168,7 @@ void IMB_colormanagement_check_file_config(Main *bmain)
        }
 }
 
-void IMB_colormanagement_validate_settings(ColorManagedDisplaySettings *display_settings,
+void IMB_colormanagement_validate_settings(const ColorManagedDisplaySettings *display_settings,
                                            ColorManagedViewSettings *view_settings)
 {
        ColorManagedDisplay *display;