diff options
author | Pablo Dobarro <pablodp606@gmail.com> | 2020-09-18 01:42:24 +0300 |
---|---|---|
committer | Pablo Dobarro <pablodp606@gmail.com> | 2020-09-18 20:15:15 +0300 |
commit | 5855f317a7070d69dbb94761c5a2c2f53b058a6e (patch) | |
tree | b1070a52d3f6bb432ebfcf95052890be06b2ab32 | |
parent | 5d728d38b94c2e48865de0e90fb433dbc1845fe0 (diff) |
LookDev: Lock HDRI rotation to View
This adds an option for the HDRI rotation to follow the view rotation.
When this option is enabled, this allows EEVEE materials to be used as
matcaps for sculpting and painting.
This has an extra performance cost when orbiting around the model as the
lookdev cache needs to be recalculated, but in my test it is barely
noticeable.
Reviewed By: fclem
Differential Revision: https://developer.blender.org/D8566
-rw-r--r-- | release/scripts/startup/bl_ui/space_view3d.py | 8 | ||||
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_lookdev.c | 17 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_view3d_types.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 9 |
4 files changed, 34 insertions, 1 deletions
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 6bd5532dd68..269237e804c 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -5720,7 +5720,13 @@ class VIEW3D_PT_shading_lighting(Panel): split = layout.split(factor=0.9) col = split.column() - col.prop(shading, "studiolight_rotate_z", text="Rotation") + + row = col.row() + row.prop(shading, "use_studiolight_view_rotation", text="", icon='WORLD', toggle=True) + row = row.row() + row.active = shading.use_world_space_lighting + row.prop(shading, "studiolight_rotate_z", text="Rotation") + col.prop(shading, "studiolight_intensity") col.prop(shading, "studiolight_background_alpha") col.prop(shading, "studiolight_background_blur") diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c index 2ca234ad5bd..5deaf4d4d68 100644 --- a/source/blender/draw/engines/eevee/eevee_lookdev.c +++ b/source/blender/draw/engines/eevee/eevee_lookdev.c @@ -198,6 +198,20 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata, DRWShadingGroup *grp = DRW_shgroup_create(shader, pass); axis_angle_to_mat3_single(g_data->studiolight_matrix, 'Z', shading->studiolight_rot_z); + + float studiolight_matrix[3][3] = {{0.0f}}; + if (shading->flag & V3D_SHADING_STUDIOLIGHT_VIEW_ROTATION) { + float view_matrix[4][4]; + float view_rot_matrix[3][3]; + float x_rot_matrix[3][3]; + DRW_view_viewmat_get(NULL, view_matrix, false); + copy_m3_m4(view_rot_matrix, view_matrix); + axis_angle_to_mat3_single(x_rot_matrix, 'X', M_PI / 2.0f); + mul_m3_m3m3(view_rot_matrix, x_rot_matrix, view_rot_matrix); + mul_m3_m3m3(view_rot_matrix, g_data->studiolight_matrix, view_rot_matrix); + copy_m3_m3(studiolight_matrix, view_rot_matrix); + } + DRW_shgroup_uniform_mat3(grp, "StudioLightMatrix", g_data->studiolight_matrix); if (probe_render) { @@ -222,6 +236,8 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata, /* Do we need to recalc the lightprobes? */ if (g_data->studiolight_index != sl->index || + (shading->flag & V3D_SHADING_STUDIOLIGHT_VIEW_ROTATION && + !equals_m3m3(g_data->studiolight_matrix, studiolight_matrix)) || g_data->studiolight_rot_z != shading->studiolight_rot_z || g_data->studiolight_intensity != shading->studiolight_intensity || g_data->studiolight_cubemap_res != scene->eevee.gi_cubemap_resolution || @@ -229,6 +245,7 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata, g_data->studiolight_filter_quality != scene->eevee.gi_filter_quality) { stl->lookdev_lightcache->flag |= LIGHTCACHE_UPDATE_WORLD; g_data->studiolight_index = sl->index; + copy_m3_m3(g_data->studiolight_matrix, studiolight_matrix); g_data->studiolight_rot_z = shading->studiolight_rot_z; g_data->studiolight_intensity = shading->studiolight_intensity; g_data->studiolight_cubemap_res = scene->eevee.gi_cubemap_resolution; diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 7bfdc14d25c..64f26a756db 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -479,6 +479,7 @@ enum { V3D_SHADING_DEPTH_OF_FIELD = (1 << 11), V3D_SHADING_SCENE_LIGHTS_RENDER = (1 << 12), V3D_SHADING_SCENE_WORLD_RENDER = (1 << 13), + V3D_SHADING_STUDIOLIGHT_VIEW_ROTATION = (1 << 14), }; /** #View3DShading.cavity_type */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index d33939724ef..213326eff8c 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -3345,6 +3345,15 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_SHADING, NULL); + prop = RNA_def_property(srna, "use_studiolight_view_rotation", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna( + prop, NULL, "flag", V3D_SHADING_STUDIOLIGHT_VIEW_ROTATION); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_boolean_default(prop, false); + RNA_def_property_ui_text( + prop, "World Space Lighting", "Make the HDR rotation fixed and not follow the camera"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_SHADING, NULL); + prop = RNA_def_property(srna, "color_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "color_type"); RNA_def_property_enum_items(prop, rna_enum_shading_color_type_items); |