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:
-rw-r--r--release/scripts/startup/bl_ui/space_view3d.py1
-rw-r--r--source/blender/blenkernel/intern/scene.c5
-rw-r--r--source/blender/blenloader/intern/versioning_280.c10
-rw-r--r--source/blender/blenloader/intern/versioning_defaults.c4
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl3
-rw-r--r--source/blender/draw/engines/workbench/workbench_data.c4
-rw-r--r--source/blender/draw/engines/workbench/workbench_deferred.c11
-rw-r--r--source/blender/makesdna/DNA_scene_types.h3
-rw-r--r--source/blender/makesrna/intern/rna_scene.c9
9 files changed, 40 insertions, 10 deletions
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 4f8d2ae34aa..4900ed6e631 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -4402,6 +4402,7 @@ class VIEW3D_PT_shading_options_shadow(Panel):
col = layout.column()
col.prop(scene.display, "light_direction")
col.prop(scene.display, "shadow_shift")
+ col.prop(scene.display, "shadow_focus")
class VIEW3D_PT_shading_options_ssao(Panel):
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 090c016ed00..7a6f1ec85b4 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -858,8 +858,9 @@ void BKE_scene_init(Scene *sce)
BKE_view_layer_add(sce, "View Layer");
/* SceneDisplay */
- copy_v3_v3(sce->display.light_direction, (float[3]){-M_SQRT1_3, -M_SQRT1_3, M_SQRT1_3});
- sce->display.shadow_shift = 0.1;
+ copy_v3_v3(sce->display.light_direction, (float[3]){M_SQRT1_3, M_SQRT1_3, M_SQRT1_3});
+ sce->display.shadow_shift = 0.1f;
+ sce->display.shadow_focus = 0.0f;
sce->display.matcap_ssao_distance = 0.2f;
sce->display.matcap_ssao_attenuation = 1.0f;
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 434153fc7b9..17859d257d0 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -2480,5 +2480,15 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
+
+ /* Change Solid mode shadow orientation. */
+ if (!DNA_struct_elem_find(fd->filesdna, "SceneDisplay", "float", "shadow_focus")) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+ float *dir = scene->display.light_direction;
+ SWAP(float, dir[2], dir[1]);
+ dir[2] = -dir[2];
+ dir[0] = -dir[0];
+ }
+ }
}
}
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index b88618bf7db..25946a9fb31 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -301,4 +301,8 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
}
}
}
+
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+ copy_v3_v3(scene->display.light_direction, (float[3]){M_SQRT1_3, M_SQRT1_3, M_SQRT1_3});
+ }
}
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl
index 310169bdf5d..e383d1b1939 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl
@@ -16,6 +16,7 @@ uniform vec4 viewvecs[3];
uniform float shadowMultiplier;
uniform float lightMultiplier;
uniform float shadowShift = 0.1;
+uniform float shadowFocus = 1.0;
layout(std140) uniform world_block {
WorldData world_data;
@@ -99,7 +100,7 @@ void main()
float light_factor = -dot(normal_viewport, world_data.shadow_direction_vs.xyz);
/* The step function might be ok for meshes but it's
* clearly not the case for hairs. Do smoothstep in this case. */
- float shadow_mix = smoothstep(1.0, shadowShift, light_factor);
+ float shadow_mix = smoothstep(shadowFocus, shadowShift, light_factor);
shaded_color *= mix(lightMultiplier, shadowMultiplier, shadow_mix);
#endif
diff --git a/source/blender/draw/engines/workbench/workbench_data.c b/source/blender/draw/engines/workbench/workbench_data.c
index 1cdf4c2b443..04e760f1909 100644
--- a/source/blender/draw/engines/workbench/workbench_data.c
+++ b/source/blender/draw/engines/workbench/workbench_data.c
@@ -161,7 +161,9 @@ void workbench_private_data_get_light_direction(WORKBENCH_PrivateData *wpd, floa
DRW_viewport_matrix_get(view_matrix, DRW_MAT_VIEW);
copy_v3_v3(r_light_direction, scene->display.light_direction);
- negate_v3(r_light_direction);
+ SWAP(float, r_light_direction[2], r_light_direction[1]);
+ r_light_direction[2] = -r_light_direction[2];
+ r_light_direction[0] = -r_light_direction[0];
/* Shadow direction. */
mul_v3_mat3_m4v3(wd->shadow_direction_vs, view_matrix, r_light_direction);
diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c
index 1ca76da672a..a77179fa676 100644
--- a/source/blender/draw/engines/workbench/workbench_deferred.c
+++ b/source/blender/draw/engines/workbench/workbench_deferred.c
@@ -566,7 +566,10 @@ void workbench_deferred_cache_init(WORKBENCH_Data *vedata)
workbench_private_data_get_light_direction(wpd, e_data.display.light_direction);
studiolight_update_light(wpd, e_data.display.light_direction);
- e_data.display.shadow_shift = scene->display.shadow_shift;
+ float shadow_focus = scene->display.shadow_focus;
+ /* Clamp to avoid overshadowing and shading errors. */
+ CLAMP(shadow_focus, 0.0001f, 0.99999f);
+ shadow_focus = 1.0f - shadow_focus * (1.0f - scene->display.shadow_shift);
if (SHADOW_ENABLED(wpd)) {
psl->composite_pass = DRW_pass_create(
@@ -576,7 +579,8 @@ void workbench_deferred_cache_init(WORKBENCH_Data *vedata)
DRW_shgroup_stencil_mask(grp, 0x00);
DRW_shgroup_uniform_float_copy(grp, "lightMultiplier", 1.0f);
DRW_shgroup_uniform_float(grp, "shadowMultiplier", &wpd->shadow_multiplier, 1);
- DRW_shgroup_uniform_float(grp, "shadowShift", &scene->display.shadow_shift, 1);
+ DRW_shgroup_uniform_float_copy(grp, "shadowShift", scene->display.shadow_shift);
+ DRW_shgroup_uniform_float_copy(grp, "shadowFocus", shadow_focus);
DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
/* Stencil Shadow passes. */
@@ -614,7 +618,8 @@ void workbench_deferred_cache_init(WORKBENCH_Data *vedata)
workbench_composite_uniforms(wpd, grp);
DRW_shgroup_uniform_float(grp, "lightMultiplier", &wpd->shadow_multiplier, 1);
DRW_shgroup_uniform_float(grp, "shadowMultiplier", &wpd->shadow_multiplier, 1);
- DRW_shgroup_uniform_float(grp, "shadowShift", &scene->display.shadow_shift, 1);
+ DRW_shgroup_uniform_float_copy(grp, "shadowShift", scene->display.shadow_shift);
+ DRW_shgroup_uniform_float_copy(grp, "shadowFocus", shadow_focus);
DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
#endif
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 6cc689378ea..1b31e45b30e 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1441,13 +1441,12 @@ typedef struct DisplaySafeAreas {
/* Scene Display - used for store scene specific display settings for the 3d view */
typedef struct SceneDisplay {
float light_direction[3]; /* light direction for shadows/highlight */
- float shadow_shift;
+ float shadow_shift, shadow_focus;
/* Settings for Cavity Shader */
float matcap_ssao_distance;
float matcap_ssao_attenuation;
int matcap_ssao_samples;
- int pad;
/* OpenGL render engine settings. */
View3DShading shading;
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index d6d597aac73..3e3e08459ca 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -5591,7 +5591,6 @@ static void rna_def_scene_display(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_set_update");
prop = RNA_def_property(srna, "shadow_shift", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_sdna(prop, NULL, "shadow_shift");
RNA_def_property_float_default(prop, 0.1);
RNA_def_property_ui_text(prop, "Shadow Shift", "Shadow termination angle");
RNA_def_property_range(prop, 0.0f, 1.0f);
@@ -5599,6 +5598,14 @@ static void rna_def_scene_display(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_set_update");
+ prop = RNA_def_property(srna, "shadow_focus", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_default(prop, 0.0);
+ RNA_def_property_ui_text(prop, "Shadow Focus", "Shadow factor hardness");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, 2);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_set_update");
+
prop = RNA_def_property(srna, "matcap_ssao_distance", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_default(prop, 0.2f);
RNA_def_property_ui_text(prop, "Distance", "Distance of object that contribute to the Cavity/Edge effect");