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:
authorBrecht Van Lommel <brecht@blender.org>2020-06-01 00:49:10 +0300
committerBrecht Van Lommel <brecht@blender.org>2020-06-24 16:17:36 +0300
commit0a3bde63006c66b8b8531ed5eccca9bdf5e5dc20 (patch)
treecf4a577e1fb0cfdaf0c47d56879ae49a21b68c1d /source/blender/blenloader/intern/versioning_cycles.c
parent88157b9efb2027380c4083d06e4ed61d8d109cef (diff)
Cycles: add denoising settings to the render properties
Enabling render and viewport denoising is now both done from the render properties. View layers still can individually be enabled/disabled for denoising and have their own denoising parameters. Note that the denoising engine also affects how denoising data passes are output even if no denoising happens on the render itself, to make the passes compatible with the engine. This includes internal refactoring for how denoising parameters are passed along, trying to avoid code duplication and unclear naming. Ref T76259
Diffstat (limited to 'source/blender/blenloader/intern/versioning_cycles.c')
-rw-r--r--source/blender/blenloader/intern/versioning_cycles.c77
1 files changed, 74 insertions, 3 deletions
diff --git a/source/blender/blenloader/intern/versioning_cycles.c b/source/blender/blenloader/intern/versioning_cycles.c
index ff3d4574561..72ee4c5ec4d 100644
--- a/source/blender/blenloader/intern/versioning_cycles.c
+++ b/source/blender/blenloader/intern/versioning_cycles.c
@@ -78,22 +78,45 @@ static IDProperty *cycles_properties_from_ID(ID *id)
return (idprop) ? IDP_GetPropertyTypeFromGroup(idprop, "cycles", IDP_GROUP) : NULL;
}
+static IDProperty *cycles_properties_from_view_layer(ViewLayer *view_layer)
+{
+ IDProperty *idprop = view_layer->id_properties;
+ return (idprop) ? IDP_GetPropertyTypeFromGroup(idprop, "cycles", IDP_GROUP) : NULL;
+}
+
static float cycles_property_float(IDProperty *idprop, const char *name, float default_value)
{
IDProperty *prop = IDP_GetPropertyTypeFromGroup(idprop, name, IDP_FLOAT);
return (prop) ? IDP_Float(prop) : default_value;
}
-static float cycles_property_int(IDProperty *idprop, const char *name, int default_value)
+static int cycles_property_int(IDProperty *idprop, const char *name, int default_value)
{
IDProperty *prop = IDP_GetPropertyTypeFromGroup(idprop, name, IDP_INT);
return (prop) ? IDP_Int(prop) : default_value;
}
-static bool cycles_property_boolean(IDProperty *idprop, const char *name, bool default_value)
+static void cycles_property_int_set(IDProperty *idprop, const char *name, int value)
{
IDProperty *prop = IDP_GetPropertyTypeFromGroup(idprop, name, IDP_INT);
- return (prop) ? IDP_Int(prop) : default_value;
+ if (prop) {
+ IDP_Int(prop) = value;
+ }
+ else {
+ IDPropertyTemplate val = {0};
+ val.i = value;
+ IDP_AddToGroup(idprop, IDP_New(IDP_INT, &val, name));
+ }
+}
+
+static bool cycles_property_boolean(IDProperty *idprop, const char *name, bool default_value)
+{
+ return cycles_property_int(idprop, name, default_value);
+}
+
+static void cycles_property_boolean_set(IDProperty *idprop, const char *name, bool value)
+{
+ cycles_property_int_set(idprop, name, value);
}
static void displacement_node_insert(bNodeTree *ntree)
@@ -1524,4 +1547,52 @@ void do_versions_after_linking_cycles(Main *bmain)
}
FOREACH_NODETREE_END;
}
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 290, 5)) {
+ /* New denoiser settings. */
+ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
+ IDProperty *cscene = cycles_properties_from_ID(&scene->id);
+
+ /* Check if any view layers had (optix) denoising enabled. */
+ bool use_optix = false;
+ bool use_denoising = false;
+ for (ViewLayer *view_layer = scene->view_layers.first; view_layer;
+ view_layer = view_layer->next) {
+ IDProperty *cview_layer = cycles_properties_from_view_layer(view_layer);
+ if (cview_layer) {
+ use_denoising = use_denoising ||
+ cycles_property_boolean(cview_layer, "use_denoising", false);
+ use_optix = use_optix ||
+ cycles_property_boolean(cview_layer, "use_optix_denoising", false);
+ }
+ }
+
+ if (cscene) {
+ const int DENOISER_NLM = 1;
+ const int DENOISER_OPTIX = 2;
+
+ /* Enable denoiser if it was enabled for one view layer before. */
+ cycles_property_int_set(cscene, "denoiser", (use_optix) ? DENOISER_OPTIX : DENOISER_NLM);
+ cycles_property_boolean_set(cscene, "use_denoising", use_denoising);
+
+ /* Migrate Optix denoiser to new settings. */
+ if (cycles_property_int(cscene, "preview_denoising", 0)) {
+ cycles_property_boolean_set(cscene, "use_preview_denoising", true);
+ cycles_property_boolean_set(cscene, "preview_denoiser", DENOISER_OPTIX);
+ }
+ }
+
+ /* Enable denoising in all view layer if there was no denoising before,
+ * so that enabling the scene settings auto enables it for all view layers. */
+ if (!use_denoising) {
+ for (ViewLayer *view_layer = scene->view_layers.first; view_layer;
+ view_layer = view_layer->next) {
+ IDProperty *cview_layer = cycles_properties_from_view_layer(view_layer);
+ if (cview_layer) {
+ cycles_property_boolean_set(cview_layer, "use_denoising", true);
+ }
+ }
+ }
+ }
+ }
}