Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/draw/engines/eevee/eevee_lookdev.c')
-rw-r--r--source/blender/draw/engines/eevee/eevee_lookdev.c53
1 files changed, 41 insertions, 12 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c
index 2ca234ad5bd..710d2c70479 100644
--- a/source/blender/draw/engines/eevee/eevee_lookdev.c
+++ b/source/blender/draw/engines/eevee/eevee_lookdev.c
@@ -95,24 +95,13 @@ static void eevee_lookdev_hdri_preview_init(EEVEE_Data *vedata, EEVEE_ViewLayerD
}
}
-void EEVEE_lookdev_cache_init(EEVEE_Data *vedata,
- EEVEE_ViewLayerData *sldata,
- DRWPass *pass,
- EEVEE_LightProbesInfo *pinfo,
- DRWShadingGroup **r_shgrp)
+void EEVEE_lookdev_init(EEVEE_Data *vedata)
{
EEVEE_StorageList *stl = vedata->stl;
- EEVEE_TextureList *txl = vedata->txl;
EEVEE_EffectsInfo *effects = stl->effects;
- EEVEE_PrivateData *g_data = stl->g_data;
const DRWContextState *draw_ctx = DRW_context_state_get();
/* The view will be NULL when rendering previews. */
const View3D *v3d = draw_ctx->v3d;
- const Scene *scene = draw_ctx->scene;
-
- const bool probe_render = pinfo != NULL;
-
- effects->lookdev_view = NULL;
if (eevee_hdri_preview_overlay_enabled(v3d)) {
/* Viewport / Spheres size. */
@@ -142,9 +131,32 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata,
effects->sphere_size = sphere_size;
effects->anchor[0] = rect->xmax;
effects->anchor[1] = rect->ymin;
+ stl->g_data->valid_double_buffer = false;
EEVEE_temporal_sampling_reset(vedata);
}
+ }
+}
+void EEVEE_lookdev_cache_init(EEVEE_Data *vedata,
+ EEVEE_ViewLayerData *sldata,
+ DRWPass *pass,
+ EEVEE_LightProbesInfo *pinfo,
+ DRWShadingGroup **r_shgrp)
+{
+ EEVEE_StorageList *stl = vedata->stl;
+ EEVEE_TextureList *txl = vedata->txl;
+ EEVEE_EffectsInfo *effects = stl->effects;
+ EEVEE_PrivateData *g_data = stl->g_data;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ /* The view will be NULL when rendering previews. */
+ const View3D *v3d = draw_ctx->v3d;
+ const Scene *scene = draw_ctx->scene;
+
+ const bool probe_render = pinfo != NULL;
+
+ effects->lookdev_view = NULL;
+
+ if (eevee_hdri_preview_overlay_enabled(v3d)) {
eevee_lookdev_hdri_preview_init(vedata, sldata);
}
@@ -198,6 +210,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 +248,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 +257,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;