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 /source/blender/draw | |
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
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_lookdev.c | 17 |
1 files changed, 17 insertions, 0 deletions
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; |