From 14897fb6533a6fcfdb665a215b8daf72b6550574 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 29 Apr 2019 14:14:14 +1000 Subject: Cleanup: spelling --- intern/cycles/blender/blender_sync.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 0ab6d88487e..8d93d517d4e 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -583,7 +583,7 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLa } /* Cryptomatte stores two ID/weight pairs per RGBA layer. - * User facing paramter is the number of pairs. */ + * User facing parameter is the number of pairs. */ int crypto_depth = min(16, get_int(crp, "pass_crypto_depth")) / 2; scene->film->cryptomatte_depth = crypto_depth; scene->film->cryptomatte_passes = CRYPT_NONE; -- cgit v1.2.3 From 4f386999ea92ad0f22bffa151581cf5c615c660b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 26 Jun 2019 14:28:26 +0200 Subject: Fix T66111: animated lights not updating in Cycles --- intern/cycles/blender/blender_sync.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 8d93d517d4e..95ecb4200c2 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -216,6 +216,10 @@ void BlenderSync::sync_data(BL::RenderSettings &b_render, mesh_synced.clear(); + /* Shader sync done at the end, since object sync uses it. + * false = don't delete unused shaders, not supported. */ + shader_map.post_sync(false); + free_data_after_sync(b_depsgraph); } -- cgit v1.2.3 From c9238e638fd5f6b3e4cf22d879d397dee1b09b48 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 28 Jun 2019 17:06:32 +0200 Subject: Cycles: add back control to render first N bounces with path termination It's found in the Sampling > Advanced panel and 0 by default. This helps to reduce noise in some scenes, while making others slower. --- intern/cycles/blender/blender_sync.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 95ecb4200c2..bac571b02ce 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -235,6 +235,7 @@ void BlenderSync::sync_integrator() Integrator *integrator = scene->integrator; Integrator previntegrator = *integrator; + integrator->min_bounce = get_int(cscene, "min_light_bounces"); integrator->max_bounce = get_int(cscene, "max_bounces"); integrator->max_diffuse_bounce = get_int(cscene, "diffuse_bounces"); @@ -242,6 +243,7 @@ void BlenderSync::sync_integrator() integrator->max_transmission_bounce = get_int(cscene, "transmission_bounces"); integrator->max_volume_bounce = get_int(cscene, "volume_bounces"); + integrator->transparent_min_bounce = get_int(cscene, "min_transparent_bounces"); integrator->transparent_max_bounce = get_int(cscene, "transparent_max_bounces"); integrator->volume_max_steps = get_int(cscene, "volume_max_steps"); -- cgit v1.2.3 From 133dfdd704b6a2a4d46337696773b331a44304ea Mon Sep 17 00:00:00 2001 From: OmarSquircleArt Date: Wed, 21 Aug 2019 20:04:09 +0200 Subject: Shading: Add White Noise node. The White Noise node hashes the input and returns a random number in the range [0, 1]. The input can be a 1D, 2D, 3D, or a 4D vector. Reviewers: brecht, JacquesLucke Differential Revision: https://developer.blender.org/D5550 --- intern/cycles/blender/blender_sync.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index bac571b02ce..aec21887088 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -255,13 +255,13 @@ void BlenderSync::sync_integrator() integrator->seed = get_int(cscene, "seed"); if (get_boolean(cscene, "use_animated_seed")) { - integrator->seed = hash_int_2d(b_scene.frame_current(), get_int(cscene, "seed")); + integrator->seed = hash_uint2(b_scene.frame_current(), get_int(cscene, "seed")); if (b_scene.frame_subframe() != 0.0f) { /* TODO(sergey): Ideally should be some sort of hash_merge, * but this is good enough for now. */ - integrator->seed += hash_int_2d((int)(b_scene.frame_subframe() * (float)INT_MAX), - get_int(cscene, "seed")); + integrator->seed += hash_uint2((int)(b_scene.frame_subframe() * (float)INT_MAX), + get_int(cscene, "seed")); } } -- cgit v1.2.3 From 68d1f091583168dce4e52d3c7378b9b0359e903a Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Tue, 27 Aug 2019 15:47:30 +0200 Subject: 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 --- intern/cycles/blender/blender_sync.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index aec21887088..e50d96cf345 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -80,7 +80,7 @@ BlenderSync::~BlenderSync() /* Sync */ -void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph) +void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d) { /* Sync recalc flags from blender to cycles. Actual update is done separate, * so we can do it later on if doing it immediate is not suitable. */ @@ -175,6 +175,11 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph) } } + BlenderViewportParameters new_viewport_parameters(b_v3d); + if (viewport_parameters.modified(new_viewport_parameters)) { + world_recalc = true; + } + /* Updates shader with object dependency if objects changed. */ if (has_updated_objects) { if (scene->default_background->has_object_dependency) { @@ -202,7 +207,7 @@ void BlenderSync::sync_data(BL::RenderSettings &b_render, sync_view_layer(b_v3d, b_view_layer); sync_integrator(); sync_film(); - sync_shaders(b_depsgraph); + sync_shaders(b_depsgraph, b_v3d); sync_images(); sync_curve_settings(); @@ -210,9 +215,9 @@ void BlenderSync::sync_data(BL::RenderSettings &b_render, if (scene->need_motion() == Scene::MOTION_PASS || scene->need_motion() == Scene::MOTION_NONE || scene->camera->motion_position == Camera::MOTION_POSITION_CENTER) { - sync_objects(b_depsgraph); + sync_objects(b_depsgraph, b_v3d); } - sync_motion(b_render, b_depsgraph, b_override, width, height, python_thread_state); + sync_motion(b_render, b_depsgraph, b_v3d, b_override, width, height, python_thread_state); mesh_synced.clear(); -- cgit v1.2.3 From 7e61e597253f3ca75f2fb86a57212ca750ffbbe8 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Thu, 5 Sep 2019 12:47:20 +0200 Subject: Cycles: Display RenderPass in Viewport This change allows the user to select a renderpass in the 3d viewport. Added support for external renderers to extend the `View3DShading` struct. This way Blender doesn't need to know the features an external render engine wants to support. Note that the View3DShading is also available in the scene->display.shading; although this is supported, it does not make sense for render engines to put something here as it is really scene/workbench related. Currently cycles assumes that it always needs to calculate the combined pass; it ignores the `pass_flag` in KernelFilm. We could optimize this but that was not in scope of this change Reviewed By: brecht Differential Revision: https://developer.blender.org/D5689 --- intern/cycles/blender/blender_sync.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index e50d96cf345..8b7c66363d9 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -206,7 +206,7 @@ void BlenderSync::sync_data(BL::RenderSettings &b_render, sync_view_layer(b_v3d, b_view_layer); sync_integrator(); - sync_film(); + sync_film(b_v3d); sync_shaders(b_depsgraph, b_v3d); sync_images(); sync_curve_settings(); @@ -336,13 +336,17 @@ void BlenderSync::sync_integrator() /* Film */ -void BlenderSync::sync_film() +void BlenderSync::sync_film(BL::SpaceView3D &b_v3d) { PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); Film *film = scene->film; Film prevfilm = *film; + if (b_v3d) { + film->display_pass = update_viewport_display_passes(b_v3d, film->passes, true); + } + film->exposure = get_float(cscene, "film_exposure"); film->filter_type = (FilterType)get_enum( cscene, "pixel_filter_type", FILTER_NUM_TYPES, FILTER_BLACKMAN_HARRIS); @@ -368,8 +372,10 @@ void BlenderSync::sync_film() } } - if (film->modified(prevfilm)) + if (film->modified(prevfilm)) { film->tag_update(scene); + film->tag_passes_update(scene, prevfilm.passes, false); + } } /* Render Layer */ -- cgit v1.2.3 From a2b52dc5716a97e5413acbd6eefc9ce3788b6456 Mon Sep 17 00:00:00 2001 From: Patrick Mours Date: Thu, 12 Sep 2019 14:50:06 +0200 Subject: Cycles: add Optix device backend This uses hardware-accelerated raytracing on NVIDIA RTX graphics cards. It is still currently experimental. Most features are supported, but a few are still missing like baking, branched path tracing and using CPU memory. https://wiki.blender.org/wiki/Reference/Release_Notes/2.81/Cycles#NVIDIA_RTX For building with Optix support, the Optix SDK must be installed. See here for build instructions: https://wiki.blender.org/wiki/Building_Blender/CUDA Differential Revision: https://developer.blender.org/D5363 --- intern/cycles/blender/blender_sync.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 8b7c66363d9..1a166d171bc 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -758,7 +758,7 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine &b_engine, preview_samples = preview_samples * preview_samples; } - if (get_enum(cscene, "progressive") == 0) { + if (get_enum(cscene, "progressive") == 0 && (params.device.type != DEVICE_OPTIX)) { if (background) { params.samples = aa_samples; } -- cgit v1.2.3 From 271c6794d6295e0022a4088cd0bf6b0592b7abf2 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Fri, 13 Sep 2019 12:43:57 +0200 Subject: Cycles: Viewport Rendering Memory Improvement Small memory reduction change by only storing the pixels of the combined pass when it is being shown in the viewport. Previously the combined pass was always calculated and present in the output buffer. The combined pass will still be calculated. It is a limitation in Blender that Cycles always had a combined pass. This patch will remove the limitation from the code base of Cycles. Blender still has the limitation, but will always request the combined renderpass when doing final rendering. Reviewed By: brecht Differential Revision: https://developer.blender.org/D5784 --- intern/cycles/blender/blender_sync.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 1a166d171bc..f04455ff75e 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -344,7 +344,7 @@ void BlenderSync::sync_film(BL::SpaceView3D &b_v3d) Film prevfilm = *film; if (b_v3d) { - film->display_pass = update_viewport_display_passes(b_v3d, film->passes, true); + film->display_pass = update_viewport_display_passes(b_v3d, film->passes); } film->exposure = get_float(cscene, "film_exposure"); @@ -520,7 +520,6 @@ int BlenderSync::get_denoising_pass(BL::RenderPass &b_pass) vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLayer &b_view_layer) { vector passes; - Pass::add(PASS_COMBINED, passes); /* loop over passes */ BL::RenderLayer::passes_iterator b_pass_iter; -- cgit v1.2.3 From e760972221e68d3c81f2ee3687cc71836dde8ae9 Mon Sep 17 00:00:00 2001 From: Lukas Stockner Date: Wed, 4 Dec 2019 19:57:28 +0100 Subject: Cycles: support for custom shader AOVs Custom render passes are added in the Shader AOVs panel in the view layer settings, with a name and data type. In shader nodes, an AOV Output node is then used to output either a value or color to the pass. Arbitrary names can be used for these passes, as long as they don't conflict with built-in passes that are enabled. The AOV Output node can be used in both material and world shader nodes. Implemented by Lukas, with tweaks by Brecht. Differential Revision: https://developer.blender.org/D4837 --- intern/cycles/blender/blender_sync.cpp | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index f04455ff75e..bb52c740bfb 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -531,7 +531,7 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLa if (pass_type == PASS_MOTION && scene->integrator->motion_blur) continue; if (pass_type != PASS_NONE) - Pass::add(pass_type, passes); + Pass::add(pass_type, passes, b_pass.name().c_str()); } PointerRNA crp = RNA_pointer_get(&b_view_layer.ptr, "cycles"); @@ -570,32 +570,32 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLa #ifdef __KERNEL_DEBUG__ if (get_boolean(crp, "pass_debug_bvh_traversed_nodes")) { b_engine.add_pass("Debug BVH Traversed Nodes", 1, "X", b_view_layer.name().c_str()); - Pass::add(PASS_BVH_TRAVERSED_NODES, passes); + Pass::add(PASS_BVH_TRAVERSED_NODES, passes, "Debug BVH Traversed Nodes"); } if (get_boolean(crp, "pass_debug_bvh_traversed_instances")) { b_engine.add_pass("Debug BVH Traversed Instances", 1, "X", b_view_layer.name().c_str()); - Pass::add(PASS_BVH_TRAVERSED_INSTANCES, passes); + Pass::add(PASS_BVH_TRAVERSED_INSTANCES, passes, "Debug BVH Traversed Instances"); } if (get_boolean(crp, "pass_debug_bvh_intersections")) { b_engine.add_pass("Debug BVH Intersections", 1, "X", b_view_layer.name().c_str()); - Pass::add(PASS_BVH_INTERSECTIONS, passes); + Pass::add(PASS_BVH_INTERSECTIONS, passes, "Debug BVH Intersections"); } if (get_boolean(crp, "pass_debug_ray_bounces")) { b_engine.add_pass("Debug Ray Bounces", 1, "X", b_view_layer.name().c_str()); - Pass::add(PASS_RAY_BOUNCES, passes); + Pass::add(PASS_RAY_BOUNCES, passes, "Debug Ray Bounces"); } #endif if (get_boolean(crp, "pass_debug_render_time")) { b_engine.add_pass("Debug Render Time", 1, "X", b_view_layer.name().c_str()); - Pass::add(PASS_RENDER_TIME, passes); + Pass::add(PASS_RENDER_TIME, passes, "Debug Render Time"); } if (get_boolean(crp, "use_pass_volume_direct")) { b_engine.add_pass("VolumeDir", 3, "RGB", b_view_layer.name().c_str()); - Pass::add(PASS_VOLUME_DIRECT, passes); + Pass::add(PASS_VOLUME_DIRECT, passes, "VolumeDir"); } if (get_boolean(crp, "use_pass_volume_indirect")) { b_engine.add_pass("VolumeInd", 3, "RGB", b_view_layer.name().c_str()); - Pass::add(PASS_VOLUME_INDIRECT, passes); + Pass::add(PASS_VOLUME_INDIRECT, passes, "VolumeInd"); } /* Cryptomatte stores two ID/weight pairs per RGBA layer. @@ -635,6 +635,21 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLa CRYPT_ACCURATE); } + RNA_BEGIN (&crp, b_aov, "aovs") { + bool is_color = (get_enum(b_aov, "type") == 1); + string name = get_string(b_aov, "name"); + + if (is_color) { + b_engine.add_pass(name.c_str(), 4, "RGBA", b_view_layer.name().c_str()); + Pass::add(PASS_AOV_COLOR, passes, name.c_str()); + } + else { + b_engine.add_pass(name.c_str(), 1, "X", b_view_layer.name().c_str()); + Pass::add(PASS_AOV_VALUE, passes, name.c_str()); + } + } + RNA_END; + return passes; } -- cgit v1.2.3 From c30d6571bb47734e0bcb2fced5cf11cb6d8b1169 Mon Sep 17 00:00:00 2001 From: Lukas Stockner Date: Thu, 12 Dec 2019 16:06:08 +0100 Subject: Add support for tiled images and the UDIM naming scheme This patch contains the work that I did during my week at the Code Quest - adding support for tiled images to Blender. With this patch, images now contain a list of tiles. By default, this just contains one tile, but if the source type is set to Tiled, the user can add additional tiles. When acquiring an ImBuf, the tile to be loaded is specified in the ImageUser. Therefore, code that is not yet aware of tiles will just access the default tile as usual. The filenames of the additional tiles are derived from the original filename according to the UDIM naming scheme - the filename contains an index that is calculated as (1001 + 10* + ), where the x coordinate never goes above 9. Internally, the various tiles are stored in a cache just like sequences. When acquired for the first time, the code will try to load the corresponding file from disk. Alternatively, a new operator can be used to initialize the tile similar to the New Image operator. The following features are supported so far: - Automatic detection and loading of all tiles when opening the first tile (1001) - Saving all tiles - Adding and removing tiles - Filling tiles with generated images - Drawing all tiles in the Image Editor - Viewing a tiled grid even if no image is selected - Rendering tiled images in Eevee - Rendering tiled images in Cycles (in SVM mode) - Automatically skipping loading of unused tiles in Cycles - 2D texture painting (also across tiles) - 3D texture painting (also across tiles, only limitation: individual faces can not cross tile borders) - Assigning custom labels to individual tiles (drawn in the Image Editor instead of the ID) - Different resolutions between tiles There still are some missing features that will be added later (see T72390): - Workbench engine support - Packing/Unpacking support - Baking support - Cycles OSL support - many other Blender features that rely on images Thanks to Brecht for the review and to all who tested the intermediate versions! Differential Revision: https://developer.blender.org/D3509 --- intern/cycles/blender/blender_sync.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index bb52c740bfb..332ee3575c0 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -729,6 +729,9 @@ SceneParams BlenderSync::get_scene_params(BL::Scene &b_scene, bool background) params.bvh_layout = RNA_boolean_get(&cscene, "use_bvh_embree") ? BVH_LAYOUT_EMBREE : params.bvh_layout; #endif + + params.background = background; + return params; } -- cgit v1.2.3 From d5ca72191c36f3022db8fa5a17d933ee82c82d30 Mon Sep 17 00:00:00 2001 From: Patrick Mours Date: Wed, 11 Dec 2019 18:11:46 +0100 Subject: Cycles: Add OptiX AI denoiser support This patch adds support for the OptiX denoiser as an alternative to the existing NLM denoiser in Cycles. It's re-using the same denoising architecture based on tiles and therefore implicitly also works with multiple GPUs. Reviewed By: sergey Differential Revision: https://developer.blender.org/D6395 --- intern/cycles/blender/blender_sync.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 332ee3575c0..20dbe23cdb7 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -535,23 +535,26 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLa } PointerRNA crp = RNA_pointer_get(&b_view_layer.ptr, "cycles"); - bool full_denoising = get_boolean(crp, "use_denoising"); + bool use_denoising = get_boolean(crp, "use_denoising"); + bool use_optix_denoising = get_boolean(crp, "use_optix_denoising"); bool write_denoising_passes = get_boolean(crp, "denoising_store_passes"); scene->film->denoising_flags = 0; - if (full_denoising || write_denoising_passes) { + if (use_denoising || write_denoising_passes) { + if (!use_optix_denoising) { #define MAP_OPTION(name, flag) \ if (!get_boolean(crp, name)) \ scene->film->denoising_flags |= flag; - MAP_OPTION("denoising_diffuse_direct", DENOISING_CLEAN_DIFFUSE_DIR); - MAP_OPTION("denoising_diffuse_indirect", DENOISING_CLEAN_DIFFUSE_IND); - MAP_OPTION("denoising_glossy_direct", DENOISING_CLEAN_GLOSSY_DIR); - MAP_OPTION("denoising_glossy_indirect", DENOISING_CLEAN_GLOSSY_IND); - MAP_OPTION("denoising_transmission_direct", DENOISING_CLEAN_TRANSMISSION_DIR); - MAP_OPTION("denoising_transmission_indirect", DENOISING_CLEAN_TRANSMISSION_IND); - MAP_OPTION("denoising_subsurface_direct", DENOISING_CLEAN_SUBSURFACE_DIR); - MAP_OPTION("denoising_subsurface_indirect", DENOISING_CLEAN_SUBSURFACE_IND); + MAP_OPTION("denoising_diffuse_direct", DENOISING_CLEAN_DIFFUSE_DIR); + MAP_OPTION("denoising_diffuse_indirect", DENOISING_CLEAN_DIFFUSE_IND); + MAP_OPTION("denoising_glossy_direct", DENOISING_CLEAN_GLOSSY_DIR); + MAP_OPTION("denoising_glossy_indirect", DENOISING_CLEAN_GLOSSY_IND); + MAP_OPTION("denoising_transmission_direct", DENOISING_CLEAN_TRANSMISSION_DIR); + MAP_OPTION("denoising_transmission_indirect", DENOISING_CLEAN_TRANSMISSION_IND); + MAP_OPTION("denoising_subsurface_direct", DENOISING_CLEAN_SUBSURFACE_DIR); + MAP_OPTION("denoising_subsurface_indirect", DENOISING_CLEAN_SUBSURFACE_IND); #undef MAP_OPTION + } b_engine.add_pass("Noisy Image", 4, "RGBA", b_view_layer.name().c_str()); } @@ -559,14 +562,17 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLa b_engine.add_pass("Denoising Normal", 3, "XYZ", b_view_layer.name().c_str()); b_engine.add_pass("Denoising Albedo", 3, "RGB", b_view_layer.name().c_str()); b_engine.add_pass("Denoising Depth", 1, "Z", b_view_layer.name().c_str()); - b_engine.add_pass("Denoising Shadowing", 1, "X", b_view_layer.name().c_str()); - b_engine.add_pass("Denoising Variance", 3, "RGB", b_view_layer.name().c_str()); - b_engine.add_pass("Denoising Intensity", 1, "X", b_view_layer.name().c_str()); + if (!use_optix_denoising) { + b_engine.add_pass("Denoising Shadowing", 1, "X", b_view_layer.name().c_str()); + b_engine.add_pass("Denoising Variance", 3, "RGB", b_view_layer.name().c_str()); + b_engine.add_pass("Denoising Intensity", 1, "X", b_view_layer.name().c_str()); + } if (scene->film->denoising_flags & DENOISING_CLEAN_ALL_PASSES) { b_engine.add_pass("Denoising Clean", 3, "RGB", b_view_layer.name().c_str()); } } + #ifdef __KERNEL_DEBUG__ if (get_boolean(crp, "pass_debug_bvh_traversed_nodes")) { b_engine.add_pass("Debug BVH Traversed Nodes", 1, "X", b_view_layer.name().c_str()); -- cgit v1.2.3 From 7b66f73558d1e4dda308366bc8ad2b5dfa8009d3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 2 Feb 2020 13:09:18 +0100 Subject: Cleanup: export particle hair as a separate Cycles object --- intern/cycles/blender/blender_sync.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 20dbe23cdb7..bb8a132ebb7 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -108,10 +108,12 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d } if (dicing_prop_changed) { - for (const pair &iter : mesh_map.key_to_scene_data()) { + for (const pair &iter : mesh_map.key_to_scene_data()) { Mesh *mesh = iter.second; if (mesh->subdivision_type != Mesh::SUBDIVISION_NONE) { - mesh_map.set_recalc(iter.first); + PointerRNA id_ptr; + RNA_id_pointer_create((::ID *)iter.first.id, &id_ptr); + mesh_map.set_recalc(BL::ID(id_ptr)); } } } -- cgit v1.2.3 From d9c5f0d25fc91b069158ae1ab4fddc21bfd85846 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 2 Feb 2020 12:04:19 +0100 Subject: Cleanup: split Cycles Hair and Mesh classes, with Geometry base class --- intern/cycles/blender/blender_sync.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index bb8a132ebb7..8960c84567e 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -56,7 +56,7 @@ BlenderSync::BlenderSync(BL::RenderEngine &b_engine, b_scene(b_scene), shader_map(&scene->shaders), object_map(&scene->objects), - mesh_map(&scene->meshes), + geometry_map(&scene->geometry), light_map(&scene->lights), particle_system_map(&scene->particle_systems), world_map(NULL), @@ -108,12 +108,15 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d } if (dicing_prop_changed) { - for (const pair &iter : mesh_map.key_to_scene_data()) { - Mesh *mesh = iter.second; - if (mesh->subdivision_type != Mesh::SUBDIVISION_NONE) { - PointerRNA id_ptr; - RNA_id_pointer_create((::ID *)iter.first.id, &id_ptr); - mesh_map.set_recalc(BL::ID(id_ptr)); + for (const pair &iter : geometry_map.key_to_scene_data()) { + Geometry *geom = iter.second; + if (geom->type == Geometry::MESH) { + Mesh *mesh = static_cast(geom); + if (mesh->subdivision_type != Mesh::SUBDIVISION_NONE) { + PointerRNA id_ptr; + RNA_id_pointer_create((::ID *)iter.first.id, &id_ptr); + geometry_map.set_recalc(BL::ID(id_ptr)); + } } } } @@ -148,7 +151,7 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d if (updated_geometry || (object_subdivision_type(b_ob, preview, experimental) != Mesh::SUBDIVISION_NONE)) { BL::ID key = BKE_object_is_modified(b_ob) ? b_ob : b_ob.data(); - mesh_map.set_recalc(key); + geometry_map.set_recalc(key); } } else if (object_is_light(b_ob)) { @@ -166,7 +169,7 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d /* Mesh */ else if (b_id.is_a(&RNA_Mesh)) { BL::Mesh b_mesh(b_id); - mesh_map.set_recalc(b_mesh); + geometry_map.set_recalc(b_mesh); } /* World */ else if (b_id.is_a(&RNA_World)) { @@ -213,7 +216,7 @@ void BlenderSync::sync_data(BL::RenderSettings &b_render, sync_images(); sync_curve_settings(); - mesh_synced.clear(); /* use for objects and motion sync */ + geometry_synced.clear(); /* use for objects and motion sync */ if (scene->need_motion() == Scene::MOTION_PASS || scene->need_motion() == Scene::MOTION_NONE || scene->camera->motion_position == Camera::MOTION_POSITION_CENTER) { @@ -221,7 +224,7 @@ void BlenderSync::sync_data(BL::RenderSettings &b_render, } sync_motion(b_render, b_depsgraph, b_v3d, b_override, width, height, python_thread_state); - mesh_synced.clear(); + geometry_synced.clear(); /* Shader sync done at the end, since object sync uses it. * false = don't delete unused shaders, not supported. */ -- cgit v1.2.3 From 38589de10c098cfe32ac7716f4d7844abf959753 Mon Sep 17 00:00:00 2001 From: Patrick Mours Date: Tue, 11 Feb 2020 16:30:01 +0100 Subject: Cycles: Add support for denoising in the viewport The OptiX denoiser can be a great help when rendering in the viewport, since it is really fast and needs few samples to produce convincing results. This patch therefore adds support for using any Cycles denoiser in the viewport also (but only the OptiX one is selectable because the NLM one is too slow to be usable currently). It also adds support for denoising on a different device than rendering (so one can e.g. render with the CPU but denoise with OptiX). Reviewed By: #cycles, brecht Differential Revision: https://developer.blender.org/D6554 --- intern/cycles/blender/blender_sync.cpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 8960c84567e..0412654d3bd 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -846,20 +846,10 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine &b_engine, /* progressive refine */ BL::RenderSettings b_r = b_scene.render(); - params.progressive_refine = (b_engine.is_preview() || - get_boolean(cscene, "use_progressive_refine")) && - !b_r.use_save_buffers(); - - if (params.progressive_refine) { - BL::Scene::view_layers_iterator b_view_layer; - for (b_scene.view_layers.begin(b_view_layer); b_view_layer != b_scene.view_layers.end(); - ++b_view_layer) { - PointerRNA crl = RNA_pointer_get(&b_view_layer->ptr, "cycles"); - if (get_boolean(crl, "use_denoising")) { - params.progressive_refine = false; - } - } - } + params.progressive_refine = b_engine.is_preview() || + get_boolean(cscene, "use_progressive_refine"); + if (b_r.use_save_buffers()) + params.progressive_refine = false; if (background) { if (params.progressive_refine) -- cgit v1.2.3 From e0085bfd24da3dcfb30498ad8c579620042aa6c5 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 14 Feb 2020 12:20:12 +0100 Subject: Cycles: move sss and diffuse transmission into diffuse pass This simplifies compositors setups and will be consistent with Eevee render passes from D6331. There's a continuum between these passes and it's not clear there is much advantage to having them available separately. Differential Revision: https://developer.blender.org/D6848 --- intern/cycles/blender/blender_sync.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 0412654d3bd..bfa3df1b295 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -461,19 +461,16 @@ PassType BlenderSync::get_pass_type(BL::RenderPass &b_pass) MAP_PASS("DiffDir", PASS_DIFFUSE_DIRECT); MAP_PASS("GlossDir", PASS_GLOSSY_DIRECT); MAP_PASS("TransDir", PASS_TRANSMISSION_DIRECT); - MAP_PASS("SubsurfaceDir", PASS_SUBSURFACE_DIRECT); MAP_PASS("VolumeDir", PASS_VOLUME_DIRECT); MAP_PASS("DiffInd", PASS_DIFFUSE_INDIRECT); MAP_PASS("GlossInd", PASS_GLOSSY_INDIRECT); MAP_PASS("TransInd", PASS_TRANSMISSION_INDIRECT); - MAP_PASS("SubsurfaceInd", PASS_SUBSURFACE_INDIRECT); MAP_PASS("VolumeInd", PASS_VOLUME_INDIRECT); MAP_PASS("DiffCol", PASS_DIFFUSE_COLOR); MAP_PASS("GlossCol", PASS_GLOSSY_COLOR); MAP_PASS("TransCol", PASS_TRANSMISSION_COLOR); - MAP_PASS("SubsurfaceCol", PASS_SUBSURFACE_COLOR); MAP_PASS("Emit", PASS_EMISSION); MAP_PASS("Env", PASS_BACKGROUND); @@ -556,8 +553,6 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLa MAP_OPTION("denoising_glossy_indirect", DENOISING_CLEAN_GLOSSY_IND); MAP_OPTION("denoising_transmission_direct", DENOISING_CLEAN_TRANSMISSION_DIR); MAP_OPTION("denoising_transmission_indirect", DENOISING_CLEAN_TRANSMISSION_IND); - MAP_OPTION("denoising_subsurface_direct", DENOISING_CLEAN_SUBSURFACE_DIR); - MAP_OPTION("denoising_subsurface_indirect", DENOISING_CLEAN_SUBSURFACE_IND); #undef MAP_OPTION } b_engine.add_pass("Noisy Image", 4, "RGBA", b_view_layer.name().c_str()); -- cgit v1.2.3 From 0c09700f20646bb4083063bfe525e05d52e79b10 Mon Sep 17 00:00:00 2001 From: Patrick Mours Date: Tue, 25 Feb 2020 13:31:08 +0100 Subject: Cycles: Add option to change which sample to start viewport denoising at This patch adds a new user-configurable option to change at which sample viewport denoising should kick in. Setting it to zero retains previous behavior (start immediately), while other values will defer denoising until the particular sample has been reached. Default is now at one, to avoid the weirdness that is AI denoising at small resolutions. Reviewed By: brecht Differential Revision: https://developer.blender.org/D6906 --- intern/cycles/blender/blender_sync.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index bfa3df1b295..50442c6ebdc 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -832,6 +832,7 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine &b_engine, /* other parameters */ params.start_resolution = get_int(cscene, "preview_start_resolution"); + params.denoising_start_sample = get_int(cscene, "preview_denoising_start_sample"); params.pixel_size = b_engine.get_preview_pixel_size(b_scene); /* other parameters */ -- cgit v1.2.3 From 51e898324de30c0985a80e5bc067358b5ccedbfc Mon Sep 17 00:00:00 2001 From: Stefan Werner Date: Thu, 5 Mar 2020 12:05:42 +0100 Subject: Adaptive Sampling for Cycles. This feature takes some inspiration from "RenderMan: An Advanced Path Tracing Architecture for Movie Rendering" and "A Hierarchical Automatic Stopping Condition for Monte Carlo Global Illumination" The basic principle is as follows: While samples are being added to a pixel, the adaptive sampler writes half of the samples to a separate buffer. This gives it two separate estimates of the same pixel, and by comparing their difference it estimates convergence. Once convergence drops below a given threshold, the pixel is considered done. When a pixel has not converged yet and needs more samples than the minimum, its immediate neighbors are also set to take more samples. This is done in order to more reliably detect sharp features such as caustics. A 3x3 box filter that is run periodically over the tile buffer is used for that purpose. After a tile has finished rendering, the values of all passes are scaled as if they were rendered with the full number of samples. This way, any code operating on these buffers, for example the denoiser, does not need to be changed for per-pixel sample counts. Reviewed By: brecht, #cycles Differential Revision: https://developer.blender.org/D4686 --- intern/cycles/blender/blender_sync.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 50442c6ebdc..8f00f9ccda0 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -296,6 +296,16 @@ void BlenderSync::sync_integrator() integrator->sample_all_lights_indirect = get_boolean(cscene, "sample_all_lights_indirect"); integrator->light_sampling_threshold = get_float(cscene, "light_sampling_threshold"); + if (RNA_boolean_get(&cscene, "use_adaptive_sampling")) { + integrator->sampling_pattern = SAMPLING_PATTERN_PMJ; + integrator->adaptive_min_samples = get_int(cscene, "adaptive_min_samples"); + integrator->adaptive_threshold = get_float(cscene, "adaptive_threshold"); + } + else { + integrator->adaptive_min_samples = INT_MAX; + integrator->adaptive_threshold = 0.0f; + } + int diffuse_samples = get_int(cscene, "diffuse_samples"); int glossy_samples = get_int(cscene, "glossy_samples"); int transmission_samples = get_int(cscene, "transmission_samples"); @@ -312,6 +322,8 @@ void BlenderSync::sync_integrator() integrator->mesh_light_samples = mesh_light_samples * mesh_light_samples; integrator->subsurface_samples = subsurface_samples * subsurface_samples; integrator->volume_samples = volume_samples * volume_samples; + integrator->adaptive_min_samples = min( + integrator->adaptive_min_samples * integrator->adaptive_min_samples, INT_MAX); } else { integrator->diffuse_samples = diffuse_samples; @@ -484,6 +496,8 @@ PassType BlenderSync::get_pass_type(BL::RenderPass &b_pass) MAP_PASS("Debug Ray Bounces", PASS_RAY_BOUNCES); #endif MAP_PASS("Debug Render Time", PASS_RENDER_TIME); + MAP_PASS("AdaptiveAuxBuffer", PASS_ADAPTIVE_AUX_BUFFER); + MAP_PASS("Debug Sample Count", PASS_SAMPLE_COUNT); if (string_startswith(name, cryptomatte_prefix)) { return PASS_CRYPTOMATTE; } @@ -519,7 +533,9 @@ int BlenderSync::get_denoising_pass(BL::RenderPass &b_pass) return -1; } -vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLayer &b_view_layer) +vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, + BL::ViewLayer &b_view_layer, + bool adaptive_sampling) { vector passes; @@ -595,6 +611,10 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLa b_engine.add_pass("Debug Render Time", 1, "X", b_view_layer.name().c_str()); Pass::add(PASS_RENDER_TIME, passes, "Debug Render Time"); } + if (get_boolean(crp, "pass_debug_sample_count")) { + b_engine.add_pass("Debug Sample Count", 1, "X", b_view_layer.name().c_str()); + Pass::add(PASS_SAMPLE_COUNT, passes, "Debug Sample Count"); + } if (get_boolean(crp, "use_pass_volume_direct")) { b_engine.add_pass("VolumeDir", 3, "RGB", b_view_layer.name().c_str()); Pass::add(PASS_VOLUME_DIRECT, passes, "VolumeDir"); @@ -641,6 +661,13 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLa CRYPT_ACCURATE); } + if (adaptive_sampling) { + Pass::add(PASS_ADAPTIVE_AUX_BUFFER, passes); + if (!get_boolean(crp, "pass_debug_sample_count")) { + Pass::add(PASS_SAMPLE_COUNT, passes); + } + } + RNA_BEGIN (&crp, b_aov, "aovs") { bool is_color = (get_enum(b_aov, "type") == 1); string name = get_string(b_aov, "name"); @@ -880,6 +907,8 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine &b_engine, params.use_profiling = params.device.has_profiling && !b_engine.is_preview() && background && BlenderSession::print_render_stats; + params.adaptive_sampling = RNA_boolean_get(&cscene, "use_adaptive_sampling"); + return params; } -- cgit v1.2.3 From 796683db8edb98adf2165fed458d08454cb7c977 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 11 Mar 2020 11:22:13 +0100 Subject: Cycles: add view layer setting to exclude volumes, like hair and surfaces --- intern/cycles/blender/blender_sync.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 8f00f9ccda0..4529c6a2798 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -405,6 +405,7 @@ void BlenderSync::sync_view_layer(BL::SpaceView3D & /*b_v3d*/, BL::ViewLayer &b_ view_layer.use_background_ao = b_view_layer.use_ao(); view_layer.use_surfaces = b_view_layer.use_solid(); view_layer.use_hair = b_view_layer.use_strand(); + view_layer.use_volumes = b_view_layer.use_volumes(); /* Material override. */ view_layer.material_override = b_view_layer.material_override(); -- cgit v1.2.3 From 994eb1ec17efc6d0a035356d04354bfc97bf8077 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 17 Mar 2020 16:52:14 +0100 Subject: Cycles: support rendering new Volume object type Voxels are loaded directly from the OpenVDB grid. Rendering still only supports dense grid, so memory usage is not great for sparse volumes, this is to be addressed in the future. Ref T73201 --- intern/cycles/blender/blender_sync.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 4529c6a2798..3d932825ae7 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -178,6 +178,11 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d world_recalc = true; } } + /* Volume */ + else if (b_id.is_a(&RNA_Volume)) { + BL::Volume b_volume(b_id); + geometry_map.set_recalc(b_volume); + } } BlenderViewportParameters new_viewport_parameters(b_v3d); -- cgit v1.2.3 From 1162ba206dd7792414d3ae716877ba1383de8dab Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 7 Mar 2020 14:38:52 +0100 Subject: Cycles: change volume step size controls, auto adjust based on voxel size By default it will now set the step size to the voxel size for smoke and volume objects, and 1/10th the bounding box for procedural volume shaders. New settings are: * Scene render/preview step rate: to globally adjust detail and performance * Material step rate: multiplied with auto detected per-object step size * World step size: distance to steo for world shader Differential Revision: https://developer.blender.org/D1777 --- intern/cycles/blender/blender_sync.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 3d932825ae7..9f7797efb97 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -262,7 +262,8 @@ void BlenderSync::sync_integrator() integrator->transparent_max_bounce = get_int(cscene, "transparent_max_bounces"); integrator->volume_max_steps = get_int(cscene, "volume_max_steps"); - integrator->volume_step_size = get_float(cscene, "volume_step_size"); + integrator->volume_step_rate = (preview) ? get_float(cscene, "volume_preview_step_rate") : + get_float(cscene, "volume_step_rate"); integrator->caustics_reflective = get_boolean(cscene, "caustics_reflective"); integrator->caustics_refractive = get_boolean(cscene, "caustics_refractive"); -- cgit v1.2.3 From 2d1cce8331f3ecdfb8cb0c651e111ffac5dc7153 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Thu, 19 Mar 2020 09:33:03 +0100 Subject: Cleanup: `make format` after SortedIncludes change --- intern/cycles/blender/blender_sync.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 9f7797efb97..91d715af7e2 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -16,6 +16,7 @@ #include "render/background.h" #include "render/camera.h" +#include "render/curves.h" #include "render/film.h" #include "render/graph.h" #include "render/integrator.h" @@ -25,19 +26,18 @@ #include "render/object.h" #include "render/scene.h" #include "render/shader.h" -#include "render/curves.h" #include "device/device.h" #include "blender/blender_device.h" -#include "blender/blender_sync.h" #include "blender/blender_session.h" +#include "blender/blender_sync.h" #include "blender/blender_util.h" #include "util/util_debug.h" #include "util/util_foreach.h" -#include "util/util_opengl.h" #include "util/util_hash.h" +#include "util/util_opengl.h" CCL_NAMESPACE_BEGIN -- cgit v1.2.3 From 3033b2a0442fad0af9a2f57054397fec4efba97b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 21 Mar 2020 01:37:00 +0100 Subject: Fix T73372: cryptomatte not filling last pass for odd number of levels Make logic consistent with the render pass creation in Python. --- intern/cycles/blender/blender_sync.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 91d715af7e2..28a737c3341 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -633,12 +633,12 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, /* Cryptomatte stores two ID/weight pairs per RGBA layer. * User facing parameter is the number of pairs. */ - int crypto_depth = min(16, get_int(crp, "pass_crypto_depth")) / 2; + int crypto_depth = min(16, get_int(crp, "pass_crypto_depth")); scene->film->cryptomatte_depth = crypto_depth; scene->film->cryptomatte_passes = CRYPT_NONE; if (get_boolean(crp, "use_pass_crypto_object")) { - for (int i = 0; i < crypto_depth; ++i) { - string passname = cryptomatte_prefix + string_printf("Object%02d", i); + for (int i = 0; i < crypto_depth; i += 2) { + string passname = cryptomatte_prefix + string_printf("Object%02d", i / 2); b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str()); Pass::add(PASS_CRYPTOMATTE, passes, passname.c_str()); } @@ -646,8 +646,8 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, CRYPT_OBJECT); } if (get_boolean(crp, "use_pass_crypto_material")) { - for (int i = 0; i < crypto_depth; ++i) { - string passname = cryptomatte_prefix + string_printf("Material%02d", i); + for (int i = 0; i < crypto_depth; i += 2) { + string passname = cryptomatte_prefix + string_printf("Material%02d", i / 2); b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str()); Pass::add(PASS_CRYPTOMATTE, passes, passname.c_str()); } @@ -655,8 +655,8 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, CRYPT_MATERIAL); } if (get_boolean(crp, "use_pass_crypto_asset")) { - for (int i = 0; i < crypto_depth; ++i) { - string passname = cryptomatte_prefix + string_printf("Asset%02d", i); + for (int i = 0; i < crypto_depth; i += 2) { + string passname = cryptomatte_prefix + string_printf("Asset%02d", i / 2); b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str()); Pass::add(PASS_CRYPTOMATTE, passes, passname.c_str()); } -- cgit v1.2.3 From 80513d85747c80f8c88800928885bae1f980580d Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 3 Apr 2020 01:47:23 +0200 Subject: Fix T75287: other Cycles render passes wrong when using Cryptomatte --- intern/cycles/blender/blender_sync.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 28a737c3341..9e95cdb3f20 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -633,12 +633,12 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, /* Cryptomatte stores two ID/weight pairs per RGBA layer. * User facing parameter is the number of pairs. */ - int crypto_depth = min(16, get_int(crp, "pass_crypto_depth")); + int crypto_depth = divide_up(min(16, get_int(crp, "pass_crypto_depth")), 2); scene->film->cryptomatte_depth = crypto_depth; scene->film->cryptomatte_passes = CRYPT_NONE; if (get_boolean(crp, "use_pass_crypto_object")) { - for (int i = 0; i < crypto_depth; i += 2) { - string passname = cryptomatte_prefix + string_printf("Object%02d", i / 2); + for (int i = 0; i < crypto_depth; i++) { + string passname = cryptomatte_prefix + string_printf("Object%02d", i); b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str()); Pass::add(PASS_CRYPTOMATTE, passes, passname.c_str()); } @@ -646,8 +646,8 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, CRYPT_OBJECT); } if (get_boolean(crp, "use_pass_crypto_material")) { - for (int i = 0; i < crypto_depth; i += 2) { - string passname = cryptomatte_prefix + string_printf("Material%02d", i / 2); + for (int i = 0; i < crypto_depth; i++) { + string passname = cryptomatte_prefix + string_printf("Material%02d", i); b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str()); Pass::add(PASS_CRYPTOMATTE, passes, passname.c_str()); } @@ -655,8 +655,8 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, CRYPT_MATERIAL); } if (get_boolean(crp, "use_pass_crypto_asset")) { - for (int i = 0; i < crypto_depth; i += 2) { - string passname = cryptomatte_prefix + string_printf("Asset%02d", i / 2); + for (int i = 0; i < crypto_depth; i++) { + string passname = cryptomatte_prefix + string_printf("Asset%02d", i); b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str()); Pass::add(PASS_CRYPTOMATTE, passes, passname.c_str()); } -- cgit v1.2.3 From 6c9a88234038f500c3e75472088f14dff05d073b Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Wed, 22 Apr 2020 13:50:21 +0200 Subject: Fix T75964: changing object's viewport display color does not update cycles Caused by rB00466e756e33. While that commit sounds logical, Cycles uses is_updated_transform() to detect updates. Now introduce is_updated_shading() and use that on top. Maniphest Tasks: T75964 Differential Revision: https://developer.blender.org/D7493 --- intern/cycles/blender/blender_sync.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 9e95cdb3f20..f4c100bcd2b 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -142,7 +142,7 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d BL::Object b_ob(b_id); const bool updated_geometry = b_update->is_updated_geometry(); - if (b_update->is_updated_transform()) { + if (b_update->is_updated_transform() || b_update->is_updated_shading()) { object_map.set_recalc(b_ob); light_map.set_recalc(b_ob); } -- cgit v1.2.3 From 805a78e3965b6aed4c6a94aeb469c16fd63345f3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 30 Apr 2020 12:19:37 +0200 Subject: Cleanup: compiler warning with clang 10 --- intern/cycles/blender/blender_sync.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index f4c100bcd2b..0c120b944a7 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -108,7 +108,7 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d } if (dicing_prop_changed) { - for (const pair &iter : geometry_map.key_to_scene_data()) { + for (const pair &iter : geometry_map.key_to_scene_data()) { Geometry *geom = iter.second; if (geom->type == Geometry::MESH) { Mesh *mesh = static_cast(geom); -- cgit v1.2.3 From 16d8a683be4348b5c6eff48cbb16c7454863d9ea Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 14 May 2020 17:26:04 +0200 Subject: Fix T73984: unnecessary Cycles viewport updates with object texture coordinates Remove old code that added extra updates for shaders that have a dependency on objects. The dependency graph can now tell Cycles when a material is affected by an object transform. --- intern/cycles/blender/blender_sync.cpp | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 0c120b944a7..e8031be7dd1 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -85,8 +85,6 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d /* Sync recalc flags from blender to cycles. Actual update is done separate, * so we can do it later on if doing it immediate is not suitable. */ - bool has_updated_objects = b_depsgraph.id_type_updated(BL::DriverTarget::id_type_OBJECT); - if (experimental) { /* Mark all meshes as needing to be exported again if dicing changed. */ PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); @@ -189,19 +187,6 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d if (viewport_parameters.modified(new_viewport_parameters)) { world_recalc = true; } - - /* Updates shader with object dependency if objects changed. */ - if (has_updated_objects) { - if (scene->default_background->has_object_dependency) { - world_recalc = true; - } - - foreach (Shader *shader, scene->shaders) { - if (shader->has_object_dependency) { - shader->need_sync_object = true; - } - } - } } void BlenderSync::sync_data(BL::RenderSettings &b_render, -- cgit v1.2.3 From d9773edaa394f61393f9c8b80275e62f74306097 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 10 May 2019 21:39:58 +0200 Subject: Cycles: code refactor to bake using regular render session and tiles There should be no user visible change from this, except that tile size now affects performance. The goal here is to simplify bake denoising in D3099, letting it reuse more denoising tiles and pass code. A lot of code is now shared with regular rendering, with the two main differences being that we read some render result passes from the bake API when starting to render a tile, and call the bake kernel instead of the path trace kernel. With this kind of design where Cycles asks for tiles from the bake API, it should eventually be easier to reduce memory usage, show tiles as they are baked, or bake multiple passes at once, though there's still quite some work needed for that. Reviewers: #cycles Subscribers: monio, wmatyjewicz, lukasstockner97, michaelknubben Differential Revision: https://developer.blender.org/D3108 --- intern/cycles/blender/blender_sync.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index e8031be7dd1..f16305e737d 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -481,6 +481,9 @@ PassType BlenderSync::get_pass_type(BL::RenderPass &b_pass) MAP_PASS("AO", PASS_AO); MAP_PASS("Shadow", PASS_SHADOW); + MAP_PASS("BakePrimitive", PASS_BAKE_PRIMITIVE); + MAP_PASS("BakeDifferential", PASS_BAKE_DIFFERENTIAL); + #ifdef __KERNEL_DEBUG__ MAP_PASS("Debug BVH Traversed Nodes", PASS_BVH_TRAVERSED_NODES); MAP_PASS("Debug BVH Traversed Instances", PASS_BVH_TRAVERSED_INSTANCES); -- cgit v1.2.3 From 79e529c5ec16d644693c1a71790819e020a293cd Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 27 May 2020 18:00:59 +0200 Subject: Fix T77109: Cycles viewport render crash after object add and undo --- intern/cycles/blender/blender_sync.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index e8031be7dd1..90736b7630d 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -78,6 +78,14 @@ BlenderSync::~BlenderSync() { } +void BlenderSync::reset(BL::BlendData &b_data, BL::Scene &b_scene) +{ + /* Update data and scene pointers in case they change in session reset, + * for example after undo. */ + this->b_data = b_data; + this->b_scene = b_scene; +} + /* Sync */ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d) -- cgit v1.2.3 From 63930c41bc3abf784d29091246b952a5c9d848b3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 10 Jun 2020 19:03:15 +0200 Subject: Fix Cycles viewport missing refresh when changing scene hair settings This code was not updated for the CoW depsgraph. --- intern/cycles/blender/blender_sync.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 2605799f593..09813dc8c05 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -212,7 +212,7 @@ void BlenderSync::sync_data(BL::RenderSettings &b_render, sync_film(b_v3d); sync_shaders(b_depsgraph, b_v3d); sync_images(); - sync_curve_settings(); + sync_curve_settings(b_depsgraph); geometry_synced.clear(); /* use for objects and motion sync */ -- cgit v1.2.3 From d1ef5146d72d40f97fdcbf28e96da49193c21dea Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 10 Jun 2020 18:55:33 +0200 Subject: Cycles: remove SIMD BVH optimizations, to be replaced by Embree Ref T73778 Depends on D8011 Maniphest Tasks: T73778 Differential Revision: https://developer.blender.org/D8012 --- intern/cycles/blender/blender_sync.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 09813dc8c05..f5fd6f31c75 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -751,15 +751,7 @@ SceneParams BlenderSync::get_scene_params(BL::Scene &b_scene, bool background) params.texture_limit = 0; } - /* TODO(sergey): Once OSL supports per-microarchitecture optimization get - * rid of this. - */ - if (params.shadingsystem == SHADINGSYSTEM_OSL) { - params.bvh_layout = BVH_LAYOUT_BVH4; - } - else { - params.bvh_layout = DebugFlags().cpu.bvh_layout; - } + params.bvh_layout = DebugFlags().cpu.bvh_layout; #ifdef WITH_EMBREE params.bvh_layout = RNA_boolean_get(&cscene, "use_bvh_embree") ? BVH_LAYOUT_EMBREE : -- cgit v1.2.3 From 2c41c8e94fa8740f67dc39150dd1ab66b506adc9 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 10 Jun 2020 19:07:07 +0200 Subject: Cycles: internal refactoring to make thick/ribbon curve separate primitives Also removing the curve system manager which only stored a few curve intersection settings. These are all changes towards making shape and subdivision settings per-object instead of per-scene, but there is more work to do here. Ref T73778 Depends on D8013 Maniphest Tasks: T73778 Differential Revision: https://developer.blender.org/D8014 --- intern/cycles/blender/blender_sync.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index f5fd6f31c75..7a6047ca6a6 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -212,7 +212,6 @@ void BlenderSync::sync_data(BL::RenderSettings &b_render, sync_film(b_v3d); sync_shaders(b_depsgraph, b_v3d); sync_images(); - sync_curve_settings(b_depsgraph); geometry_synced.clear(); /* use for objects and motion sync */ @@ -732,6 +731,11 @@ SceneParams BlenderSync::get_scene_params(BL::Scene &b_scene, bool background) params.use_bvh_unaligned_nodes = RNA_boolean_get(&cscene, "debug_use_hair_bvh"); params.num_bvh_time_steps = RNA_int_get(&cscene, "debug_bvh_time_steps"); + PointerRNA csscene = RNA_pointer_get(&b_scene.ptr, "cycles_curves"); + params.hair_subdivisions = get_int(csscene, "subdivisions"); + params.hair_shape = (CurveShapeType)get_enum( + csscene, "shape", CURVE_NUM_SHAPE_TYPES, CURVE_THICK); + if (background && params.shadingsystem != SHADINGSYSTEM_OSL) params.persistent_data = r.use_persistent_data(); else -- cgit v1.2.3 From 99436acde8fbb7381f095922bb61455b0c8fb9a9 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 23 Feb 2020 09:14:52 +0100 Subject: Cycles: enable Embree by default for CPU rendering For GPU debugging purposes, it is still possible to render with the same BVH2 on the CPU using the Debug panel in the render properties. Note that building Blender without Embree will now lead to significantly reduced performance in CPU rendering, and a few of the Cycles regression tests will fail due to small pixel differences. Ref T73778 Depends on D8014 Maniphest Tasks: T73778 Differential Revision: https://developer.blender.org/D8015 --- intern/cycles/blender/blender_sync.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 7a6047ca6a6..b40c8434395 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -757,11 +757,6 @@ SceneParams BlenderSync::get_scene_params(BL::Scene &b_scene, bool background) params.bvh_layout = DebugFlags().cpu.bvh_layout; -#ifdef WITH_EMBREE - params.bvh_layout = RNA_boolean_get(&cscene, "use_bvh_embree") ? BVH_LAYOUT_EMBREE : - params.bvh_layout; -#endif - params.background = background; return params; -- cgit v1.2.3 From 0a3bde63006c66b8b8531ed5eccca9bdf5e5dc20 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 31 May 2020 23:49:10 +0200 Subject: 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 --- intern/cycles/blender/blender_sync.cpp | 116 +++++++++++++++++++++++++-------- 1 file changed, 88 insertions(+), 28 deletions(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index b40c8434395..aed92cf1376 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -537,7 +537,8 @@ int BlenderSync::get_denoising_pass(BL::RenderPass &b_pass) vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLayer &b_view_layer, - bool adaptive_sampling) + bool adaptive_sampling, + const DenoiseParams &denoising) { vector passes; @@ -554,16 +555,13 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, Pass::add(pass_type, passes, b_pass.name().c_str()); } - PointerRNA crp = RNA_pointer_get(&b_view_layer.ptr, "cycles"); - bool use_denoising = get_boolean(crp, "use_denoising"); - bool use_optix_denoising = get_boolean(crp, "use_optix_denoising"); - bool write_denoising_passes = get_boolean(crp, "denoising_store_passes"); + PointerRNA crl = RNA_pointer_get(&b_view_layer.ptr, "cycles"); scene->film->denoising_flags = 0; - if (use_denoising || write_denoising_passes) { - if (!use_optix_denoising) { + if (denoising.use || denoising.store_passes) { + if (denoising.type == DENOISER_NLM) { #define MAP_OPTION(name, flag) \ - if (!get_boolean(crp, name)) \ + if (!get_boolean(crl, name)) \ scene->film->denoising_flags |= flag; MAP_OPTION("denoising_diffuse_direct", DENOISING_CLEAN_DIFFUSE_DIR); MAP_OPTION("denoising_diffuse_indirect", DENOISING_CLEAN_DIFFUSE_IND); @@ -576,11 +574,11 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, b_engine.add_pass("Noisy Image", 4, "RGBA", b_view_layer.name().c_str()); } - if (write_denoising_passes) { + if (denoising.store_passes) { b_engine.add_pass("Denoising Normal", 3, "XYZ", b_view_layer.name().c_str()); b_engine.add_pass("Denoising Albedo", 3, "RGB", b_view_layer.name().c_str()); b_engine.add_pass("Denoising Depth", 1, "Z", b_view_layer.name().c_str()); - if (!use_optix_denoising) { + if (denoising.type == DENOISER_NLM) { b_engine.add_pass("Denoising Shadowing", 1, "X", b_view_layer.name().c_str()); b_engine.add_pass("Denoising Variance", 3, "RGB", b_view_layer.name().c_str()); b_engine.add_pass("Denoising Intensity", 1, "X", b_view_layer.name().c_str()); @@ -592,46 +590,46 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, } #ifdef __KERNEL_DEBUG__ - if (get_boolean(crp, "pass_debug_bvh_traversed_nodes")) { + if (get_boolean(crl, "pass_debug_bvh_traversed_nodes")) { b_engine.add_pass("Debug BVH Traversed Nodes", 1, "X", b_view_layer.name().c_str()); Pass::add(PASS_BVH_TRAVERSED_NODES, passes, "Debug BVH Traversed Nodes"); } - if (get_boolean(crp, "pass_debug_bvh_traversed_instances")) { + if (get_boolean(crl, "pass_debug_bvh_traversed_instances")) { b_engine.add_pass("Debug BVH Traversed Instances", 1, "X", b_view_layer.name().c_str()); Pass::add(PASS_BVH_TRAVERSED_INSTANCES, passes, "Debug BVH Traversed Instances"); } - if (get_boolean(crp, "pass_debug_bvh_intersections")) { + if (get_boolean(crl, "pass_debug_bvh_intersections")) { b_engine.add_pass("Debug BVH Intersections", 1, "X", b_view_layer.name().c_str()); Pass::add(PASS_BVH_INTERSECTIONS, passes, "Debug BVH Intersections"); } - if (get_boolean(crp, "pass_debug_ray_bounces")) { + if (get_boolean(crl, "pass_debug_ray_bounces")) { b_engine.add_pass("Debug Ray Bounces", 1, "X", b_view_layer.name().c_str()); Pass::add(PASS_RAY_BOUNCES, passes, "Debug Ray Bounces"); } #endif - if (get_boolean(crp, "pass_debug_render_time")) { + if (get_boolean(crl, "pass_debug_render_time")) { b_engine.add_pass("Debug Render Time", 1, "X", b_view_layer.name().c_str()); Pass::add(PASS_RENDER_TIME, passes, "Debug Render Time"); } - if (get_boolean(crp, "pass_debug_sample_count")) { + if (get_boolean(crl, "pass_debug_sample_count")) { b_engine.add_pass("Debug Sample Count", 1, "X", b_view_layer.name().c_str()); Pass::add(PASS_SAMPLE_COUNT, passes, "Debug Sample Count"); } - if (get_boolean(crp, "use_pass_volume_direct")) { + if (get_boolean(crl, "use_pass_volume_direct")) { b_engine.add_pass("VolumeDir", 3, "RGB", b_view_layer.name().c_str()); Pass::add(PASS_VOLUME_DIRECT, passes, "VolumeDir"); } - if (get_boolean(crp, "use_pass_volume_indirect")) { + if (get_boolean(crl, "use_pass_volume_indirect")) { b_engine.add_pass("VolumeInd", 3, "RGB", b_view_layer.name().c_str()); Pass::add(PASS_VOLUME_INDIRECT, passes, "VolumeInd"); } /* Cryptomatte stores two ID/weight pairs per RGBA layer. * User facing parameter is the number of pairs. */ - int crypto_depth = divide_up(min(16, get_int(crp, "pass_crypto_depth")), 2); + int crypto_depth = divide_up(min(16, get_int(crl, "pass_crypto_depth")), 2); scene->film->cryptomatte_depth = crypto_depth; scene->film->cryptomatte_passes = CRYPT_NONE; - if (get_boolean(crp, "use_pass_crypto_object")) { + if (get_boolean(crl, "use_pass_crypto_object")) { for (int i = 0; i < crypto_depth; i++) { string passname = cryptomatte_prefix + string_printf("Object%02d", i); b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str()); @@ -640,7 +638,7 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, scene->film->cryptomatte_passes = (CryptomatteType)(scene->film->cryptomatte_passes | CRYPT_OBJECT); } - if (get_boolean(crp, "use_pass_crypto_material")) { + if (get_boolean(crl, "use_pass_crypto_material")) { for (int i = 0; i < crypto_depth; i++) { string passname = cryptomatte_prefix + string_printf("Material%02d", i); b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str()); @@ -649,7 +647,7 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, scene->film->cryptomatte_passes = (CryptomatteType)(scene->film->cryptomatte_passes | CRYPT_MATERIAL); } - if (get_boolean(crp, "use_pass_crypto_asset")) { + if (get_boolean(crl, "use_pass_crypto_asset")) { for (int i = 0; i < crypto_depth; i++) { string passname = cryptomatte_prefix + string_printf("Asset%02d", i); b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str()); @@ -658,19 +656,19 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, scene->film->cryptomatte_passes = (CryptomatteType)(scene->film->cryptomatte_passes | CRYPT_ASSET); } - if (get_boolean(crp, "pass_crypto_accurate") && scene->film->cryptomatte_passes != CRYPT_NONE) { + if (get_boolean(crl, "pass_crypto_accurate") && scene->film->cryptomatte_passes != CRYPT_NONE) { scene->film->cryptomatte_passes = (CryptomatteType)(scene->film->cryptomatte_passes | CRYPT_ACCURATE); } if (adaptive_sampling) { Pass::add(PASS_ADAPTIVE_AUX_BUFFER, passes); - if (!get_boolean(crp, "pass_debug_sample_count")) { + if (!get_boolean(crl, "pass_debug_sample_count")) { Pass::add(PASS_SAMPLE_COUNT, passes); } } - RNA_BEGIN (&crp, b_aov, "aovs") { + RNA_BEGIN (&crl, b_aov, "aovs") { bool is_color = (get_enum(b_aov, "type") == 1); string name = get_string(b_aov, "name"); @@ -773,7 +771,8 @@ bool BlenderSync::get_session_pause(BL::Scene &b_scene, bool background) SessionParams BlenderSync::get_session_params(BL::RenderEngine &b_engine, BL::Preferences &b_preferences, BL::Scene &b_scene, - bool background) + bool background, + BL::ViewLayer b_view_layer) { SessionParams params; PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); @@ -851,9 +850,22 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine &b_engine, params.tile_order = TILE_BOTTOM_TO_TOP; } - /* other parameters */ + /* Denoising */ + params.denoising = get_denoise_params(b_scene, b_view_layer, background); + + if (params.denoising.use) { + /* Add additional denoising devices if we are rendering and denoising + * with different devices. */ + params.device.add_denoising_devices(params.denoising.type); + + /* Check if denoiser is supported by device. */ + if (!(params.device.denoisers & params.denoising.type)) { + params.denoising.use = false; + } + } + + /* Viewport Performance */ params.start_resolution = get_int(cscene, "preview_start_resolution"); - params.denoising_start_sample = get_int(cscene, "preview_denoising_start_sample"); params.pixel_size = b_engine.get_preview_pixel_size(b_scene); /* other parameters */ @@ -906,4 +918,52 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine &b_engine, return params; } +DenoiseParams BlenderSync::get_denoise_params(BL::Scene &b_scene, + BL::ViewLayer &b_view_layer, + bool background) +{ + DenoiseParams denoising; + PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); + + if (background) { + /* Final Render Denoising */ + denoising.use = get_boolean(cscene, "use_denoising"); + denoising.type = (DenoiserType)get_enum(cscene, "denoiser", DENOISER_NUM, DENOISER_NONE); + + if (b_view_layer) { + PointerRNA clayer = RNA_pointer_get(&b_view_layer.ptr, "cycles"); + if (!get_boolean(clayer, "use_denoising")) { + denoising.use = false; + } + + denoising.radius = get_int(clayer, "denoising_radius"); + denoising.strength = get_float(clayer, "denoising_strength"); + denoising.feature_strength = get_float(clayer, "denoising_feature_strength"); + denoising.relative_pca = get_boolean(clayer, "denoising_relative_pca"); + denoising.optix_input_passes = get_enum(clayer, "denoising_optix_input_passes"); + + denoising.store_passes = get_boolean(clayer, "denoising_store_passes"); + } + } + else { + /* Viewport Denoising */ + denoising.use = get_boolean(cscene, "use_preview_denoising"); + denoising.type = (DenoiserType)get_enum( + cscene, "preview_denoiser", DENOISER_NUM, DENOISER_NONE); + denoising.start_sample = get_int(cscene, "preview_denoising_start_sample"); + + /* Auto select fastest denoiser. */ + if (denoising.type == DENOISER_NONE) { + if (!Device::available_devices(DEVICE_MASK_OPTIX).empty()) { + denoising.type = DENOISER_OPTIX; + } + else { + denoising.use = false; + } + } + } + + return denoising; +} + CCL_NAMESPACE_END -- cgit v1.2.3 From 669befdfbe487f76c65f54e3da0013d140d56893 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 1 Jun 2020 00:11:17 +0200 Subject: Cycles: add Intel OpenImageDenoise support for viewport denoising Compared to Optix denoise, this is usually slower since there is no GPU acceleration. Some optimizations may still be possible, in avoid copies to the GPU and/or denoising less often. The main thing is that this adds viewport denoising support for computers without an NVIDIA GPU (as long as the CPU supports SSE 4.1, which is nearly all of them). Ref T76259 --- intern/cycles/blender/blender_sync.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index aed92cf1376..bf065cc5492 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -38,6 +38,7 @@ #include "util/util_foreach.h" #include "util/util_hash.h" #include "util/util_opengl.h" +#include "util/util_openimagedenoise.h" CCL_NAMESPACE_BEGIN @@ -957,6 +958,9 @@ DenoiseParams BlenderSync::get_denoise_params(BL::Scene &b_scene, if (!Device::available_devices(DEVICE_MASK_OPTIX).empty()) { denoising.type = DENOISER_OPTIX; } + else if (openimagedenoise_supported()) { + denoising.type = DENOISER_OPENIMAGEDENOISE; + } else { denoising.use = false; } -- cgit v1.2.3 From e65c78cd43aa8d50612365f6b506de53d1bbfd86 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 9 Jul 2020 18:54:42 +0200 Subject: Cleanup: minor refactoring in Cycles update detection code --- intern/cycles/blender/blender_sync.cpp | 53 +++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 20 deletions(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index bf065cc5492..ee2445e44c4 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -147,30 +147,43 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d /* Object */ else if (b_id.is_a(&RNA_Object)) { BL::Object b_ob(b_id); - const bool updated_geometry = b_update->is_updated_geometry(); + const bool is_geometry = object_is_geometry(b_ob); + const bool is_light = !is_geometry && object_is_light(b_ob); - if (b_update->is_updated_transform() || b_update->is_updated_shading()) { - object_map.set_recalc(b_ob); - light_map.set_recalc(b_ob); - } + if (is_geometry || is_light) { + const bool updated_geometry = b_update->is_updated_geometry(); - if (object_is_mesh(b_ob)) { - if (updated_geometry || - (object_subdivision_type(b_ob, preview, experimental) != Mesh::SUBDIVISION_NONE)) { - BL::ID key = BKE_object_is_modified(b_ob) ? b_ob : b_ob.data(); - geometry_map.set_recalc(key); - } - } - else if (object_is_light(b_ob)) { - if (updated_geometry) { - light_map.set_recalc(b_ob); + /* Geometry (mesh, hair, volume). */ + if (is_geometry) { + if (b_update->is_updated_transform() || b_update->is_updated_shading()) { + object_map.set_recalc(b_ob); + } + + if (updated_geometry || + (object_subdivision_type(b_ob, preview, experimental) != Mesh::SUBDIVISION_NONE)) { + BL::ID key = BKE_object_is_modified(b_ob) ? b_ob : b_ob.data(); + geometry_map.set_recalc(key); + } + + if (updated_geometry) { + BL::Object::particle_systems_iterator b_psys; + for (b_ob.particle_systems.begin(b_psys); b_psys != b_ob.particle_systems.end(); + ++b_psys) { + particle_system_map.set_recalc(b_ob); + } + } } - } + /* Light */ + else if (is_light) { + if (b_update->is_updated_transform() || b_update->is_updated_shading()) { + object_map.set_recalc(b_ob); + light_map.set_recalc(b_ob); + } - if (updated_geometry) { - BL::Object::particle_systems_iterator b_psys; - for (b_ob.particle_systems.begin(b_psys); b_psys != b_ob.particle_systems.end(); ++b_psys) - particle_system_map.set_recalc(b_ob); + if (updated_geometry) { + light_map.set_recalc(b_ob); + } + } } } /* Mesh */ -- cgit v1.2.3 From 6e74a8b69f215e63e136cb4c497e738371ac798f Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 13 Jul 2020 16:45:15 +0200 Subject: Fix T78881: Cycles OpenImageDenoise not using albedo and normal correctly Properly normalize buffers now. Also expose option to not use albedo and normal just like OptiX. --- intern/cycles/blender/blender_sync.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'intern/cycles/blender/blender_sync.cpp') diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index ee2445e44c4..d509f2fc786 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -954,7 +954,13 @@ DenoiseParams BlenderSync::get_denoise_params(BL::Scene &b_scene, denoising.strength = get_float(clayer, "denoising_strength"); denoising.feature_strength = get_float(clayer, "denoising_feature_strength"); denoising.relative_pca = get_boolean(clayer, "denoising_relative_pca"); - denoising.optix_input_passes = get_enum(clayer, "denoising_optix_input_passes"); + + denoising.input_passes = (DenoiserInput)get_enum( + clayer, + (denoising.type == DENOISER_OPTIX) ? "denoising_optix_input_passes" : + "denoising_openimagedenoise_input_passes", + DENOISER_INPUT_NUM, + DENOISER_INPUT_RGB_ALBEDO_NORMAL); denoising.store_passes = get_boolean(clayer, "denoising_store_passes"); } -- cgit v1.2.3