Cycles: Use blender's use_shadow RNA property
This unify Cycles and EEVEE setting. We always copy the Cycles setting in versionning except if the first scene is using EEVEE as renderer. Note that this currently breaks importers addons who will try to `cycles.cast_shadow`property on the light. Pull Request: https://projects.blender.org/blender/blender/pulls/121804
This commit is contained in:
committed by
Clément Foucault
parent
1391b7de41
commit
1036d9bdb2
@@ -1081,11 +1081,6 @@ class CyclesMaterialSettings(bpy.types.PropertyGroup):
|
||||
|
||||
class CyclesLightSettings(bpy.types.PropertyGroup):
|
||||
|
||||
cast_shadow: BoolProperty(
|
||||
name="Cast Shadow",
|
||||
description="Light casts shadows",
|
||||
default=True,
|
||||
)
|
||||
max_bounces: IntProperty(
|
||||
name="Max Bounces",
|
||||
description="Maximum number of bounces the light will contribute to the render",
|
||||
|
||||
@@ -1620,7 +1620,7 @@ class CYCLES_LIGHT_PT_light(CyclesButtonsPanel, Panel):
|
||||
|
||||
sub = col.column(align=True)
|
||||
sub.active = not (light.type == 'AREA' and clamp.is_portal)
|
||||
sub.prop(clamp, "cast_shadow")
|
||||
sub.prop(light, "use_shadow", text="Cast Shadow")
|
||||
sub.prop(clamp, "use_multiple_importance_sampling", text="Multiple Importance")
|
||||
if use_mnee(context):
|
||||
sub.prop(clamp, "is_caustics_light", text="Shadow Caustics")
|
||||
|
||||
@@ -114,7 +114,7 @@ void BlenderSync::sync_light(BL::Object &b_parent,
|
||||
|
||||
/* shadow */
|
||||
PointerRNA clight = RNA_pointer_get(&b_light.ptr, "cycles");
|
||||
light->set_cast_shadow(get_boolean(clight, "cast_shadow"));
|
||||
light->set_cast_shadow(b_light.use_shadow());
|
||||
light->set_use_mis(get_boolean(clight, "use_multiple_importance_sampling"));
|
||||
|
||||
/* caustics light */
|
||||
|
||||
@@ -29,7 +29,7 @@ extern "C" {
|
||||
|
||||
/* Blender file format version. */
|
||||
#define BLENDER_FILE_VERSION BLENDER_VERSION
|
||||
#define BLENDER_FILE_SUBVERSION 38
|
||||
#define BLENDER_FILE_SUBVERSION 39
|
||||
|
||||
/* Minimum Blender version that supports reading file written with the current
|
||||
* version. Older Blender versions will test this and cancel loading the file, showing a warning to
|
||||
|
||||
@@ -3606,6 +3606,25 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
|
||||
}
|
||||
}
|
||||
|
||||
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 39)) {
|
||||
/* Unify cast shadow property with Cycles. */
|
||||
Scene *scene = static_cast<Scene *>(bmain->scenes.first);
|
||||
/* Be conservative, if there is no scene, still try to do the conversion as that can happen for
|
||||
* append and linking. We prefer breaking EEVEE rather than breaking Cycles here. */
|
||||
bool is_eevee = scene && STREQ(scene->r.engine, RE_engine_id_BLENDER_EEVEE);
|
||||
if (!is_eevee) {
|
||||
const Light *default_light = DNA_struct_default_get(Light);
|
||||
LISTBASE_FOREACH (Light *, light, &bmain->lights) {
|
||||
IDProperty *clight = version_cycles_properties_from_ID(&light->id);
|
||||
if (clight) {
|
||||
bool value = version_cycles_property_boolean(
|
||||
clight, "use_shadow", default_light->mode & LA_SHADOW);
|
||||
SET_FLAG_FROM_TEST(light->mode, value, LA_SHADOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Always bump subversion in BKE_blender_version.h when adding versioning
|
||||
* code here, and wrap it inside a MAIN_VERSION_FILE_ATLEAST check.
|
||||
|
||||
@@ -163,6 +163,10 @@ static void rna_def_light(BlenderRNA *brna)
|
||||
prop, "Cutoff Distance", "Distance at which the light influence will be set to 0");
|
||||
RNA_def_property_update(prop, 0, "rna_Light_update");
|
||||
|
||||
prop = RNA_def_property(srna, "use_shadow", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "mode", LA_SHADOW);
|
||||
RNA_def_property_update(prop, 0, "rna_Light_draw_update");
|
||||
|
||||
/* nodes */
|
||||
prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_pointer_sdna(prop, nullptr, "nodetree");
|
||||
@@ -229,10 +233,6 @@ static void rna_def_light_shadow(StructRNA *srna, bool sun)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
||||
prop = RNA_def_property(srna, "use_shadow", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "mode", LA_SHADOW);
|
||||
RNA_def_property_update(prop, 0, "rna_Light_draw_update");
|
||||
|
||||
prop = RNA_def_property(srna, "shadow_buffer_clip_start", PROP_FLOAT, PROP_DISTANCE);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "clipsta");
|
||||
RNA_def_property_range(prop, 1e-6f, FLT_MAX);
|
||||
|
||||
Reference in New Issue
Block a user