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
path: root/source
diff options
context:
space:
mode:
authorJeroen Bakker <j.bakker@atmind.nl>2019-08-27 16:47:30 +0300
committerJeroen Bakker <j.bakker@atmind.nl>2019-09-04 16:57:00 +0300
commit68d1f091583168dce4e52d3c7378b9b0359e903a (patch)
tree07adc7e5f8f353f4bab9f8cdd6f4fd783a13767c /source
parentd3ab930c880e3a15cd7cd46355663e60119f6bde (diff)
Shading Modes: Material and Render Preview
This change implements the basics as described in {T68312} for the shading modes. * LookDev shading mode is renamed to Material Preview. It always uses Eevee as renderer, and is intended to provide a fast material preview suitable for texture painting, and texture and material setup. * Rendered shading gains "Use Scene Lights" and "Use Scene World" options similar to current Material Preview. These will be enabled by default. When Use Scene World is turned off, HDRIs will be used for lighting instead. These options are available for EEVEE and Cycles. * Renderers will be able to customize the shading settings panel and add additional settings. Reviewed By: brecht, fclem Differential Revision: https://developer.blender.org/D5612
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_blender_version.h2
-rw-r--r--source/blender/blenkernel/intern/screen.c3
-rw-r--r--source/blender/blenloader/intern/versioning_280.c22
-rw-r--r--source/blender/draw/engines/eevee/eevee_private.h15
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c4
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_space.c95
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c6
8 files changed, 107 insertions, 42 deletions
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 65086f57616..1451f0c0d51 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -27,7 +27,7 @@
* \note Use #STRINGIFY() rather than defining with quotes.
*/
#define BLENDER_VERSION 281
-#define BLENDER_SUBVERSION 5
+#define BLENDER_SUBVERSION 6
/** Several breakages with 280, e.g. collections vs layers. */
#define BLENDER_MINVERSION 280
#define BLENDER_MINSUBVERSION 0
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index 619845c9ecb..4837fa8639e 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -856,7 +856,8 @@ void BKE_screen_view3d_shading_init(View3DShading *shading)
shading->type = OB_SOLID;
shading->prev_type = OB_SOLID;
- shading->flag = V3D_SHADING_SPECULAR_HIGHLIGHT | V3D_SHADING_XRAY_WIREFRAME;
+ shading->flag = V3D_SHADING_SPECULAR_HIGHLIGHT | V3D_SHADING_XRAY_WIREFRAME |
+ V3D_SHADING_SCENE_LIGHTS_RENDER | V3D_SHADING_SCENE_WORLD_RENDER;
shading->light = V3D_LIGHTING_STUDIO;
shading->shadow_intensity = 0.5f;
shading->xray_alpha = 0.5f;
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 45276181102..a735b399ce3 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -3732,6 +3732,28 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
+ if (!MAIN_VERSION_ATLEAST(bmain, 281, 6)) {
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->shading.flag |= V3D_SHADING_SCENE_LIGHTS_RENDER | V3D_SHADING_SCENE_WORLD_RENDER;
+
+ /* files by default don't have studio lights selected unless interacted
+ * with the shading popover. When no studiolight could be read, we will
+ * select the default world one. */
+ StudioLight *studio_light = BKE_studiolight_find(v3d->shading.lookdev_light,
+ STUDIOLIGHT_TYPE_WORLD);
+ if (studio_light != NULL) {
+ STRNCPY(v3d->shading.lookdev_light, studio_light->name);
+ }
+ }
+ }
+ }
+ }
+ }
+
{
/* Versioning code until next subversion bump goes here. */
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h
index 3cdafee95a2..fefdaef970a 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -118,16 +118,19 @@ extern struct DrawEngineType draw_engine_eevee_type;
} \
((void)0)
-#define OVERLAY_ENABLED(v3d) ((v3d) && (v3d->flag2 & V3D_HIDE_OVERLAYS) == 0)
-#define LOOK_DEV_MODE_ENABLED(v3d) ((v3d) && (v3d->shading.type == OB_MATERIAL))
+#define MATERIAL_PREVIEW_MODE_ENABLED(v3d) ((v3d) && (v3d->shading.type == OB_MATERIAL))
#define LOOK_DEV_OVERLAY_ENABLED(v3d) \
- (LOOK_DEV_MODE_ENABLED(v3d) && OVERLAY_ENABLED(v3d) && \
+ ((v3d) && (v3d->shading.type == OB_MATERIAL) && ((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) && \
(v3d->overlay.flag & V3D_OVERLAY_LOOK_DEV))
#define USE_SCENE_LIGHT(v3d) \
- ((!v3d) || (!LOOK_DEV_MODE_ENABLED(v3d)) || \
- ((LOOK_DEV_MODE_ENABLED(v3d) && (v3d->shading.flag & V3D_SHADING_SCENE_LIGHTS))))
+ ((!v3d) || \
+ ((v3d->shading.type == OB_MATERIAL) && (v3d->shading.flag & V3D_SHADING_SCENE_LIGHTS)) || \
+ ((v3d->shading.type == OB_RENDER) && (v3d->shading.flag & V3D_SHADING_SCENE_LIGHTS_RENDER)))
#define LOOK_DEV_STUDIO_LIGHT_ENABLED(v3d) \
- (LOOK_DEV_MODE_ENABLED(v3d) && !(v3d->shading.flag & V3D_SHADING_SCENE_WORLD))
+ ((v3d) && (((v3d->shading.type == OB_MATERIAL) && \
+ ((v3d->shading.flag & V3D_SHADING_SCENE_WORLD) == 0)) || \
+ ((v3d->shading.type == OB_RENDER) && \
+ ((v3d->shading.flag & V3D_SHADING_SCENE_WORLD_RENDER) == 0))))
#define OCTAHEDRAL_SIZE_FROM_CUBESIZE(cube_size) \
((int)ceilf(sqrtf((cube_size * cube_size) * 6.0f)))
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index f6afa112f08..7cd38c95a7b 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -39,6 +39,7 @@
#include "BKE_scene.h"
#include "BKE_object.h"
#include "BKE_paint.h"
+#include "BKE_studiolight.h"
#include "BKE_unit.h"
#include "BLF_api.h"
@@ -1860,6 +1861,9 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Depsgraph *depsgraph,
if (drawtype == OB_MATERIAL) {
v3d.shading.flag = V3D_SHADING_SCENE_WORLD | V3D_SHADING_SCENE_LIGHTS;
}
+ else if (drawtype == OB_RENDER) {
+ v3d.shading.flag = V3D_SHADING_SCENE_WORLD_RENDER | V3D_SHADING_SCENE_LIGHTS_RENDER;
+ }
v3d.flag2 = V3D_HIDE_OVERLAYS;
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 51655790fbd..6168b00508b 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -418,6 +418,8 @@ enum {
V3D_SHADING_WORLD_ORIENTATION = (1 << 9),
V3D_SHADING_BACKFACE_CULLING = (1 << 10),
V3D_SHADING_DEPTH_OF_FIELD = (1 << 11),
+ V3D_SHADING_SCENE_LIGHTS_RENDER = (1 << 12),
+ V3D_SHADING_SCENE_WORLD_RENDER = (1 << 13),
};
/** #View3DShading.color_type */
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index ca857fb7be8..7ad0401b0a4 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -343,7 +343,11 @@ static const EnumPropertyItem autosnap_items[] = {
const EnumPropertyItem rna_enum_shading_type_items[] = {
{OB_WIRE, "WIREFRAME", ICON_SHADING_WIRE, "Wireframe", "Display the object as wire edges"},
{OB_SOLID, "SOLID", ICON_SHADING_SOLID, "Solid", "Display in solid mode"},
- {OB_MATERIAL, "MATERIAL", ICON_SHADING_TEXTURE, "Look Dev", "Display in Look Dev mode"},
+ {OB_MATERIAL,
+ "MATERIAL",
+ ICON_SHADING_TEXTURE,
+ "Material Preview",
+ "Display in Material Preview mode"},
{OB_RENDER, "RENDERED", ICON_SHADING_RENDERED, "Rendered", "Display render preview"},
{0, NULL, 0, NULL, NULL},
};
@@ -967,6 +971,11 @@ static Scene *rna_3DViewShading_scene(PointerRNA *ptr)
{
/* Get scene, depends if using 3D view or OpenGL render settings. */
ID *id = ptr->owner_id;
+ if (!id) {
+ /* When accessed from an external render engine the id.data is NULL
+ * This might be missing from the RNA CPP Api */
+ return NULL;
+ }
if (GS(id->name) == ID_SCE) {
return (Scene *)id;
}
@@ -1054,6 +1063,7 @@ static PointerRNA rna_View3DShading_selected_studio_light_get(PointerRNA *ptr)
sl = BKE_studiolight_find(shading->studio_light, STUDIOLIGHT_FLAG_ALL);
}
else {
+ /* OB_MATERIAL and OB_RENDER */
sl = BKE_studiolight_find(shading->lookdev_light, STUDIOLIGHT_FLAG_ALL);
}
return rna_pointer_inherit_refine(ptr, &RNA_StudioLight, sl);
@@ -1088,21 +1098,32 @@ static const EnumPropertyItem *rna_View3DShading_color_type_itemf(bContext *UNUS
}
}
-/* Studio light */
-static int rna_View3DShading_studio_light_get(PointerRNA *ptr)
+static void rna_View3DShading_studio_light_get_storage(View3DShading *shading,
+ char **dna_storage,
+ int *flag)
{
- View3DShading *shading = (View3DShading *)ptr->data;
- char *dna_storage = shading->studio_light;
+ *dna_storage = shading->studio_light;
- int flag = STUDIOLIGHT_TYPE_STUDIO;
- if (shading->type == OB_SOLID && shading->light == V3D_LIGHTING_MATCAP) {
- flag = STUDIOLIGHT_TYPE_MATCAP;
- dna_storage = shading->matcap;
+ *flag = STUDIOLIGHT_TYPE_STUDIO;
+ if (shading->type == OB_SOLID) {
+ if (shading->light == V3D_LIGHTING_MATCAP) {
+ *flag = STUDIOLIGHT_TYPE_MATCAP;
+ *dna_storage = shading->matcap;
+ }
}
- else if (shading->type == OB_MATERIAL) {
- flag = STUDIOLIGHT_TYPE_WORLD;
- dna_storage = shading->lookdev_light;
+ else {
+ *flag = STUDIOLIGHT_TYPE_WORLD;
+ *dna_storage = shading->lookdev_light;
}
+}
+
+static int rna_View3DShading_studio_light_get(PointerRNA *ptr)
+{
+ View3DShading *shading = (View3DShading *)ptr->data;
+ char *dna_storage;
+ int flag;
+
+ rna_View3DShading_studio_light_get_storage(shading, &dna_storage, &flag);
StudioLight *sl = BKE_studiolight_find(dna_storage, flag);
if (sl) {
BLI_strncpy(dna_storage, sl->name, FILE_MAXFILE);
@@ -1116,17 +1137,10 @@ static int rna_View3DShading_studio_light_get(PointerRNA *ptr)
static void rna_View3DShading_studio_light_set(PointerRNA *ptr, int value)
{
View3DShading *shading = (View3DShading *)ptr->data;
- char *dna_storage = shading->studio_light;
+ char *dna_storage;
+ int flag;
- int flag = STUDIOLIGHT_TYPE_STUDIO;
- if (shading->type == OB_SOLID && shading->light == V3D_LIGHTING_MATCAP) {
- flag = STUDIOLIGHT_TYPE_MATCAP;
- dna_storage = shading->matcap;
- }
- else if (shading->type == OB_MATERIAL) {
- flag = STUDIOLIGHT_TYPE_WORLD;
- dna_storage = shading->lookdev_light;
- }
+ rna_View3DShading_studio_light_get_storage(shading, &dna_storage, &flag);
StudioLight *sl = BKE_studiolight_findindex(value, flag);
if (sl) {
BLI_strncpy(dna_storage, sl->name, FILE_MAXFILE);
@@ -1173,6 +1187,7 @@ static const EnumPropertyItem *rna_View3DShading_studio_light_itemf(bContext *UN
break;
case OB_MATERIAL:
+ case OB_RENDER:
show_studiolight = ((sl->flag & STUDIOLIGHT_TYPE_WORLD) != 0);
icon_id = sl->icon_id_radiance;
break;
@@ -3093,6 +3108,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, NULL);
+ prop = RNA_def_property(srna, "studiolight_background_alpha", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "studiolight_background");
+ RNA_def_property_float_default(prop, 0.0);
+ RNA_def_property_ui_text(prop, "Background", "Show the studiolight in the background");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_range(prop, 0.00f, 1.0f, 1, 3);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, 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);
@@ -3172,12 +3196,28 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_scene_lights", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_SCENE_LIGHTS);
+ RNA_def_property_boolean_default(prop, false);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Scene Lights", "Render lights and light probes of the scene");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "use_scene_world", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_SCENE_WORLD);
+ RNA_def_property_boolean_default(prop, false);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Scene World", "Use scene world for lighting");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "use_scene_lights_render", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_SCENE_LIGHTS_RENDER);
+ RNA_def_property_boolean_default(prop, true);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Scene Lights", "Render lights and light probes of the scene");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "use_scene_world_render", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_SCENE_WORLD_RENDER);
+ RNA_def_property_boolean_default(prop, true);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Scene World", "Use scene world for lighting");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
@@ -3203,15 +3243,6 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
RNA_def_property_ui_range(prop, 0.00f, 1.0f, 1, 3);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
-
- prop = RNA_def_property(srna, "studiolight_background_alpha", PROP_FLOAT, PROP_FACTOR);
- RNA_def_property_float_sdna(prop, NULL, "studiolight_background");
- RNA_def_property_float_default(prop, 0.0);
- RNA_def_property_ui_text(prop, "Background", "Show the studiolight in the background");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_range(prop, 0.00f, 1.0f, 1, 3);
- RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
}
static void rna_def_space_view3d_overlay(BlenderRNA *brna)
@@ -3371,7 +3402,7 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
prop = RNA_def_property(srna, "show_look_dev", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_LOOK_DEV);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_ui_text(prop, "Look Dev Preview", "Show look development spheres and palette");
+ RNA_def_property_ui_text(prop, "Look Dev Preview", "Show look development spheres");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "show_wireframes", PROP_BOOLEAN, PROP_NONE);
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index d08f4e236ee..bdc89f2bf2b 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -288,6 +288,10 @@ void WM_init(bContext *C, int argc, const char **argv)
const bool use_data = true;
const bool use_userdef = true;
+ /* Studiolights needs to be init before we read the homefile, otherwise the versioning cannot
+ * find the default studiolight.*/
+ BKE_studiolight_init();
+
wm_homefile_read(C,
NULL,
G.factory_startup,
@@ -315,8 +319,6 @@ void WM_init(bContext *C, int argc, const char **argv)
UI_init();
}
- BKE_studiolight_init();
-
ED_spacemacros_init();
/* note: there is a bug where python needs initializing before loading the