Fix T58405: viewport drawing issues with display device set to None.

Disabling color management this way is not very useful, but as long as the
option is there it should work correct.
This commit is contained in:
Brecht Van Lommel 2019-02-28 13:41:06 +01:00
parent bbe5a95d05
commit d68484a60f
Notes: blender-bot 2024-01-31 11:35:08 +01:00
Referenced by issue #59458, Color Management > Display Device: selection changes viewport background color
Referenced by issue #58405, Inconsistent Color management behavior for textures between Solid and Eevee
4 changed files with 25 additions and 5 deletions

View File

@ -59,6 +59,8 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd)
wpd->use_color_render_settings = false;
}
wpd->use_color_management = BKE_scene_check_color_management_enabled(scene);
if (wpd->shading.light == V3D_LIGHTING_MATCAP) {
wpd->studio_light = BKE_studiolight_find(
wpd->shading.matcap, STUDIOLIGHT_TYPE_MATCAP);
@ -103,8 +105,14 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd)
/* XXX: Really quick conversion to avoid washed out background.
* Needs to be addressed properly (color managed using ocio). */
srgb_to_linearrgb_v3_v3(wd->background_color_high, wd->background_color_high);
srgb_to_linearrgb_v3_v3(wd->background_color_low, wd->background_color_low);
if (wpd->use_color_management) {
srgb_to_linearrgb_v3_v3(wd->background_color_high, wd->background_color_high);
srgb_to_linearrgb_v3_v3(wd->background_color_low, wd->background_color_low);
}
else {
copy_v3_v3(wd->background_color_high, wd->background_color_high);
copy_v3_v3(wd->background_color_low, wd->background_color_low);
}
}
else {
zero_v3(wd->background_color_low);
@ -126,7 +134,12 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd)
wpd->world_clip_planes = rv3d->clip;
DRW_state_clip_planes_set_from_rv3d(rv3d);
UI_GetThemeColor4fv(TH_V3D_CLIPPING_BORDER, wpd->world_clip_planes_color);
srgb_to_linearrgb_v3_v3(wpd->world_clip_planes_color, wpd->world_clip_planes_color);
if (wpd->use_color_management) {
srgb_to_linearrgb_v3_v3(wpd->world_clip_planes_color, wpd->world_clip_planes_color);
}
else {
copy_v3_v3(wpd->world_clip_planes_color, wpd->world_clip_planes_color);
}
}
else {
wpd->world_clip_planes = NULL;

View File

@ -259,7 +259,8 @@ void workbench_material_shgroup_uniform(
if (workbench_material_determine_color_type(wpd, material->ima, ob) == V3D_SHADING_TEXTURE_COLOR) {
ImBuf *ibuf = BKE_image_acquire_ibuf(material->ima, NULL, NULL);
const bool do_color_correction = (ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0);
const bool do_color_correction = wpd->use_color_management &&
(ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0);
BKE_image_release_ibuf(material->ima, ibuf, NULL);
GPUTexture *tex = GPU_texture_from_blender(material->ima, NULL, GL_TEXTURE_2D, false);
DRW_shgroup_uniform_texture(grp, "image", tex);

View File

@ -252,6 +252,7 @@ typedef struct WORKBENCH_PrivateData {
bool dof_enabled;
/* Color Management */
bool use_color_management;
bool use_color_render_settings;
} WORKBENCH_PrivateData; /* Transient data */

View File

@ -408,7 +408,7 @@ static const EnumPropertyItem *rna_ColorManagedDisplaySettings_display_device_it
return items;
}
static void rna_ColorManagedDisplaySettings_display_device_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
static void rna_ColorManagedDisplaySettings_display_device_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
ID *id = ptr->id.data;
@ -422,6 +422,11 @@ static void rna_ColorManagedDisplaySettings_display_device_update(Main *UNUSED(b
DEG_id_tag_update(id, 0);
WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL);
/* Color management can be baked into shaders, need to refresh. */
for (Material *ma = bmain->mat.first; ma; ma = ma->id.next) {
DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
}
}
}