Python API: allow external render engines to use Eevee for LookDev shading
This is enabled with bl_use_eevee_viewport = True. It allows external engines to generate an Cycles/Eevee shader node setup to emulate their materials in the realtime viewport, or to leave it to users to do manually. Removed bl_use_exclude_layers and bl_use_shading_nodes that did nothing anymore. This should not break API compatibility, any scripts setting those should continue to work the same as before. Also adds descriptions for some RenderEngine settings.
This commit is contained in:
@@ -54,7 +54,7 @@ from . import (
|
|||||||
class CyclesRender(bpy.types.RenderEngine):
|
class CyclesRender(bpy.types.RenderEngine):
|
||||||
bl_idname = 'CYCLES'
|
bl_idname = 'CYCLES'
|
||||||
bl_label = "Cycles"
|
bl_label = "Cycles"
|
||||||
bl_use_shading_nodes = True
|
bl_use_eevee_viewport = True
|
||||||
bl_use_preview = True
|
bl_use_preview = True
|
||||||
bl_use_exclude_layers = True
|
bl_use_exclude_layers = True
|
||||||
bl_use_save_buffers = True
|
bl_use_save_buffers = True
|
||||||
|
|||||||
@@ -476,7 +476,7 @@ RenderEngineType DRW_engine_viewport_eevee_type = {
|
|||||||
NULL,
|
NULL,
|
||||||
EEVEE_ENGINE,
|
EEVEE_ENGINE,
|
||||||
N_("Eevee"),
|
N_("Eevee"),
|
||||||
RE_INTERNAL | RE_USE_SHADING_NODES | RE_USE_PREVIEW,
|
RE_INTERNAL | RE_USE_PREVIEW,
|
||||||
NULL,
|
NULL,
|
||||||
&DRW_render_to_image,
|
&DRW_render_to_image,
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
@@ -1447,13 +1447,16 @@ RenderEngineType *ED_view3d_engine_type(Scene *scene, int drawtype)
|
|||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Temporary viewport draw modes until we have a proper system.
|
* Temporary viewport draw modes until we have a proper system.
|
||||||
* all modes are done in the draw manager, except
|
* all modes are done in the draw manager, except external render
|
||||||
* cycles material as it is an external render engine.
|
* engines like Cycles.
|
||||||
*/
|
*/
|
||||||
if (strcmp(scene->r.engine, RE_engine_id_CYCLES) == 0 && drawtype == OB_MATERIAL) {
|
RenderEngineType *type = RE_engines_find(scene->r.engine);
|
||||||
|
if (drawtype == OB_MATERIAL && (type->flag & RE_USE_EEVEE_VIEWPORT)) {
|
||||||
return RE_engines_find(RE_engine_id_BLENDER_EEVEE);
|
return RE_engines_find(RE_engine_id_BLENDER_EEVEE);
|
||||||
}
|
}
|
||||||
return RE_engines_find(scene->r.engine);
|
else {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void view3d_main_region_draw(const bContext *C, ARegion *ar)
|
void view3d_main_region_draw(const bContext *C, ARegion *ar)
|
||||||
|
|||||||
@@ -844,31 +844,41 @@ static void rna_def_render_engine(BlenderRNA *brna)
|
|||||||
prop = RNA_def_property(srna, "bl_use_preview", PROP_BOOLEAN, PROP_NONE);
|
prop = RNA_def_property(srna, "bl_use_preview", PROP_BOOLEAN, PROP_NONE);
|
||||||
RNA_def_property_boolean_sdna(prop, NULL, "type->flag", RE_USE_PREVIEW);
|
RNA_def_property_boolean_sdna(prop, NULL, "type->flag", RE_USE_PREVIEW);
|
||||||
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
||||||
|
RNA_def_property_ui_text(
|
||||||
|
prop,
|
||||||
|
"Use Preview Render",
|
||||||
|
"Render engine supports being used for rendering previews of materials, lights and worlds");
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "bl_use_postprocess", PROP_BOOLEAN, PROP_NONE);
|
prop = RNA_def_property(srna, "bl_use_postprocess", PROP_BOOLEAN, PROP_NONE);
|
||||||
RNA_def_property_boolean_negative_sdna(prop, NULL, "type->flag", RE_USE_POSTPROCESS);
|
RNA_def_property_boolean_negative_sdna(prop, NULL, "type->flag", RE_USE_POSTPROCESS);
|
||||||
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
||||||
|
RNA_def_property_ui_text(prop, "Use Post Processing", "Apply compositing on render results");
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "bl_use_shading_nodes", PROP_BOOLEAN, PROP_NONE);
|
prop = RNA_def_property(srna, "bl_use_eevee_viewport", PROP_BOOLEAN, PROP_NONE);
|
||||||
RNA_def_property_boolean_sdna(prop, NULL, "type->flag", RE_USE_SHADING_NODES);
|
RNA_def_property_boolean_sdna(prop, NULL, "type->flag", RE_USE_EEVEE_VIEWPORT);
|
||||||
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
||||||
|
RNA_def_property_ui_text(
|
||||||
|
prop, "Use Eevee Viewport", "Uses Eevee for viewport shading in LookDev shading mode");
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "bl_use_shading_nodes_custom", PROP_BOOLEAN, PROP_NONE);
|
prop = RNA_def_property(srna, "bl_use_shading_nodes_custom", PROP_BOOLEAN, PROP_NONE);
|
||||||
RNA_def_property_boolean_sdna(prop, NULL, "type->flag", RE_USE_SHADING_NODES_CUSTOM);
|
RNA_def_property_boolean_sdna(prop, NULL, "type->flag", RE_USE_SHADING_NODES_CUSTOM);
|
||||||
RNA_def_property_boolean_default(prop, true);
|
RNA_def_property_boolean_default(prop, true);
|
||||||
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
||||||
|
RNA_def_property_ui_text(prop,
|
||||||
prop = RNA_def_property(srna, "bl_use_exclude_layers", PROP_BOOLEAN, PROP_NONE);
|
"Use Custom Shading Nodes",
|
||||||
RNA_def_property_boolean_sdna(prop, NULL, "type->flag", RE_USE_EXCLUDE_LAYERS);
|
"Don't expose Cycles and Eevee shading nodes in the node editor user "
|
||||||
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
"interface, so own nodes can be used instead");
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "bl_use_save_buffers", PROP_BOOLEAN, PROP_NONE);
|
prop = RNA_def_property(srna, "bl_use_save_buffers", PROP_BOOLEAN, PROP_NONE);
|
||||||
RNA_def_property_boolean_sdna(prop, NULL, "type->flag", RE_USE_SAVE_BUFFERS);
|
RNA_def_property_boolean_sdna(prop, NULL, "type->flag", RE_USE_SAVE_BUFFERS);
|
||||||
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
||||||
|
RNA_def_property_ui_text(
|
||||||
|
prop, "Use Save Buffers", "Support render to an on disk buffer during rendering");
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "bl_use_spherical_stereo", PROP_BOOLEAN, PROP_NONE);
|
prop = RNA_def_property(srna, "bl_use_spherical_stereo", PROP_BOOLEAN, PROP_NONE);
|
||||||
RNA_def_property_boolean_sdna(prop, NULL, "type->flag", RE_USE_SPHERICAL_STEREO);
|
RNA_def_property_boolean_sdna(prop, NULL, "type->flag", RE_USE_SPHERICAL_STEREO);
|
||||||
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
||||||
|
RNA_def_property_ui_text(prop, "Use Spherical Stereo", "Support spherical stereo camera models");
|
||||||
|
|
||||||
RNA_define_verify_sdna(1);
|
RNA_define_verify_sdna(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -936,8 +936,7 @@ static void rna_3DViewShading_type_update(Main *bmain, Scene *scene, PointerRNA
|
|||||||
|
|
||||||
View3DShading *shading = ptr->data;
|
View3DShading *shading = ptr->data;
|
||||||
if (shading->type == OB_MATERIAL ||
|
if (shading->type == OB_MATERIAL ||
|
||||||
(shading->type == OB_RENDER &&
|
(shading->type == OB_RENDER && !STREQ(scene->r.engine, RE_engine_id_BLENDER_WORKBENCH))) {
|
||||||
STR_ELEM(scene->r.engine, RE_engine_id_BLENDER_EEVEE, RE_engine_id_CYCLES))) {
|
|
||||||
/* When switching from workbench to render or material mode the geometry of any
|
/* When switching from workbench to render or material mode the geometry of any
|
||||||
* active sculpt session needs to be recalculated. */
|
* active sculpt session needs to be recalculated. */
|
||||||
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
|
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
|
||||||
|
|||||||
@@ -55,11 +55,10 @@ struct bNodeTree;
|
|||||||
/* #define RE_FLAG_DEPRECATED 2 */
|
/* #define RE_FLAG_DEPRECATED 2 */
|
||||||
#define RE_USE_PREVIEW 4
|
#define RE_USE_PREVIEW 4
|
||||||
#define RE_USE_POSTPROCESS 8
|
#define RE_USE_POSTPROCESS 8
|
||||||
#define RE_USE_SHADING_NODES 16
|
#define RE_USE_EEVEE_VIEWPORT 16
|
||||||
#define RE_USE_EXCLUDE_LAYERS 32
|
#define RE_USE_SAVE_BUFFERS 32
|
||||||
#define RE_USE_SAVE_BUFFERS 64
|
#define RE_USE_SHADING_NODES_CUSTOM 64
|
||||||
#define RE_USE_SHADING_NODES_CUSTOM 256
|
#define RE_USE_SPHERICAL_STEREO 128
|
||||||
#define RE_USE_SPHERICAL_STEREO 512
|
|
||||||
|
|
||||||
/* RenderEngine.flag */
|
/* RenderEngine.flag */
|
||||||
#define RE_ENGINE_ANIMATION 1
|
#define RE_ENGINE_ANIMATION 1
|
||||||
|
|||||||
Reference in New Issue
Block a user