From 1451f7d09322dbe8596c98a2cf02712097f2a879 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 20 Jan 2021 12:41:58 +0100 Subject: [PATCH 1/6] Fix T84813: enabling Cycles OpenImageDenoise during GPU viewport render fails --- intern/cycles/render/session.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/intern/cycles/render/session.h b/intern/cycles/render/session.h index ab6c0b5f124..43ff07e5884 100644 --- a/intern/cycles/render/session.h +++ b/intern/cycles/render/session.h @@ -103,10 +103,10 @@ class SessionParams { bool modified(const SessionParams ¶ms) { + /* Modified means we have to recreate the session, any parameter changes + * that can be handled by an existing Session are omitted. */ return !(device == params.device && background == params.background && progressive_refine == params.progressive_refine && - /* samples == params.samples && denoising_start_sample == - params.denoising_start_sample && */ progressive == params.progressive && experimental == params.experimental && tile_size == params.tile_size && start_resolution == params.start_resolution && pixel_size == params.pixel_size && threads == params.threads && @@ -117,7 +117,8 @@ class SessionParams { text_timeout == params.text_timeout && progressive_update_timeout == params.progressive_update_timeout && tile_order == params.tile_order && shadingsystem == params.shadingsystem && - denoising.type == params.denoising.type); + denoising.type == params.denoising.type && + (denoising.use == params.denoising.use || (device.denoisers & denoising.type))); } }; From 10d2cbfa369a512730a53192ccfe2473c9d96035 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 20 Jan 2021 13:03:09 +0100 Subject: [PATCH 2/6] Fix T84872: OptiX GPU + CPU rendering uses branched path samples Branched path tracing is not supported for OptiX, and it would still use the number of AA samples from there when branched path was enabled by the user earlier but auto disabled and hidden in the UI when using OptiX. Ref D10159 --- intern/cycles/blender/blender_sync.cpp | 2 +- intern/cycles/device/device.cpp | 2 ++ intern/cycles/device/device.h | 2 ++ intern/cycles/device/device_optix.cpp | 1 + intern/cycles/render/integrator.cpp | 6 +++--- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index b830db7485b..e27daa2488d 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -853,7 +853,7 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine &b_engine, preview_samples = preview_samples * preview_samples; } - if (get_enum(cscene, "progressive") == 0 && (params.device.type != DEVICE_OPTIX)) { + if (get_enum(cscene, "progressive") == 0 && params.device.has_branched_path) { if (background) { params.samples = aa_samples; } diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index 1efd628b79b..94732cd1855 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -620,6 +620,7 @@ DeviceInfo Device::get_multi_device(const vector &subdevices, info.has_half_images = true; info.has_volume_decoupled = true; + info.has_branched_path = true; info.has_adaptive_stop_per_sample = true; info.has_osl = true; info.has_profiling = true; @@ -665,6 +666,7 @@ DeviceInfo Device::get_multi_device(const vector &subdevices, /* Accumulate device info. */ info.has_half_images &= device.has_half_images; info.has_volume_decoupled &= device.has_volume_decoupled; + info.has_branched_path &= device.has_branched_path; info.has_adaptive_stop_per_sample &= device.has_adaptive_stop_per_sample; info.has_osl &= device.has_osl; info.has_profiling &= device.has_profiling; diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index e9b7cde7a16..0a731969c79 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -79,6 +79,7 @@ class DeviceInfo { bool display_device; /* GPU is used as a display device. */ bool has_half_images; /* Support half-float textures. */ bool has_volume_decoupled; /* Decoupled volume shading. */ + bool has_branched_path; /* Supports branched path tracing. */ bool has_adaptive_stop_per_sample; /* Per-sample adaptive sampling stopping. */ bool has_osl; /* Support Open Shading Language. */ bool use_split_kernel; /* Use split or mega kernel. */ @@ -99,6 +100,7 @@ class DeviceInfo { display_device = false; has_half_images = false; has_volume_decoupled = false; + has_branched_path = true; has_adaptive_stop_per_sample = false; has_osl = false; use_split_kernel = false; diff --git a/intern/cycles/device/device_optix.cpp b/intern/cycles/device/device_optix.cpp index f04113635f3..07ce63f5394 100644 --- a/intern/cycles/device/device_optix.cpp +++ b/intern/cycles/device/device_optix.cpp @@ -1857,6 +1857,7 @@ void device_optix_info(const vector &cuda_devices, vectorbranched = (method == BRANCHED_PATH); + kintegrator->branched = (method == BRANCHED_PATH) && device->info.has_branched_path; kintegrator->volume_decoupled = device->info.has_volume_decoupled; kintegrator->diffuse_samples = diffuse_samples; kintegrator->glossy_samples = glossy_samples; @@ -179,7 +179,7 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene kintegrator->volume_samples = volume_samples; kintegrator->start_sample = start_sample; - if (method == BRANCHED_PATH) { + if (kintegrator->branched) { kintegrator->sample_all_lights_direct = sample_all_lights_direct; kintegrator->sample_all_lights_indirect = sample_all_lights_indirect; } @@ -224,7 +224,7 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene /* sobol directions table */ int max_samples = 1; - if (method == BRANCHED_PATH) { + if (kintegrator->branched) { foreach (Light *light, scene->lights) max_samples = max(max_samples, light->get_samples()); From 1f691050e5eb1b59676d6540e712357086d2218c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 20 Jan 2021 13:27:27 +0100 Subject: [PATCH 3/6] Fix T84539: cryptomatte metadata lost when using save buffers option --- source/blender/render/intern/render_result.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/render/intern/render_result.c b/source/blender/render/intern/render_result.c index 1ed894751ce..f135adc9f05 100644 --- a/source/blender/render/intern/render_result.c +++ b/source/blender/render/intern/render_result.c @@ -1229,6 +1229,10 @@ void render_result_exr_file_begin(Render *re, RenderEngine *engine) /* end write of exr tile file, read back first sample */ void render_result_exr_file_end(Render *re, RenderEngine *engine) { + /* Preserve stamp data. */ + struct StampData *stamp_data = re->result->stamp_data; + re->result->stamp_data = NULL; + /* Close EXR files. */ for (RenderResult *rr = re->result; rr; rr = rr->next) { LISTBASE_FOREACH (RenderLayer *, rl, &rr->layers) { @@ -1243,6 +1247,7 @@ void render_result_exr_file_end(Render *re, RenderEngine *engine) BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); render_result_free_list(&re->fullresult, re->result); re->result = render_result_new(re, &re->disprect, RR_USE_MEM, RR_ALL_LAYERS, RR_ALL_VIEWS); + re->result->stamp_data = stamp_data; BLI_rw_mutex_unlock(&re->resultmutex); LISTBASE_FOREACH (RenderLayer *, rl, &re->result->layers) { From 0d599ce95a8e81c8fe4f2461f49068639e4beb2f Mon Sep 17 00:00:00 2001 From: Antonio Vazquez Date: Wed, 20 Jan 2021 16:53:42 +0100 Subject: [PATCH 4/6] GPencil: Fix unreported NaN value for UV Rotation in Primitives Using primitive drawings, the point UV rotation was not initialized. --- source/blender/editors/gpencil/gpencil_primitive.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c index b457cd819d2..33497429331 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil/gpencil_primitive.c @@ -1018,7 +1018,7 @@ static void gpencil_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) tpt->uv_fac = 0.0f; } - tpt->uv_rot = p2d->uv_rot; + tpt->uv_rot = 0.0f; gpd->runtime.sbuffer_used++; @@ -1040,6 +1040,7 @@ static void gpencil_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) pt->time = 0.0f; pt->flag = 0; pt->uv_fac = tpt->uv_fac; + pt->uv_rot = 0.0f; ED_gpencil_point_vertex_color_set(ts, brush, pt, tpt); if (gps->dvert != NULL) { From a823e825c899c30a98dd1c3fe64c5e3d72716921 Mon Sep 17 00:00:00 2001 From: Habib Gahbiche Date: Wed, 20 Jan 2021 15:02:04 +0100 Subject: [PATCH 5/6] Fix T84569: crash when trying to bake an object with no faces Differential Revision: https://developer.blender.org/D10125 --- source/blender/editors/object/object_bake_api.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c index 8a63ab22b36..113a0395e8c 100644 --- a/source/blender/editors/object/object_bake_api.c +++ b/source/blender/editors/object/object_bake_api.c @@ -441,6 +441,12 @@ static bool bake_object_check(ViewLayer *view_layer, } Mesh *me = (Mesh *)ob->data; + + if (me->totpoly == 0) { + BKE_reportf(reports, RPT_ERROR, "No faces found in the object \"%s\"", ob->id.name + 2); + return false; + } + if (target == R_BAKE_TARGET_VERTEX_COLORS) { MPropCol *mcol = CustomData_get_layer(&me->vdata, CD_PROP_COLOR); MLoopCol *mloopcol = CustomData_get_layer(&me->ldata, CD_MLOOPCOL); From b33d839162b6d4b8b85937eb095b661ac93cbddd Mon Sep 17 00:00:00 2001 From: Sebastian Parborg Date: Wed, 20 Jan 2021 18:17:25 +0100 Subject: [PATCH 6/6] Fix T84867: Transform node does not rotate/scale instances The manipulation of rot/scale was simply not implemented. --- source/blender/blenkernel/BKE_geometry_set.hh | 2 ++ source/blender/blenkernel/intern/geometry_set.cc | 10 ++++++++++ .../nodes/geometry/nodes/node_geo_transform.cc | 12 ++++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh index 391bd243edf..ad5a5d57045 100644 --- a/source/blender/blenkernel/BKE_geometry_set.hh +++ b/source/blender/blenkernel/BKE_geometry_set.hh @@ -456,6 +456,8 @@ class InstancesComponent : public GeometryComponent { blender::Span scales() const; blender::Span ids() const; blender::MutableSpan positions(); + blender::MutableSpan rotations(); + blender::MutableSpan scales(); int instances_amount() const; bool is_empty() const final; diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc index 5d2b82dcc5f..81958b81213 100644 --- a/source/blender/blenkernel/intern/geometry_set.cc +++ b/source/blender/blenkernel/intern/geometry_set.cc @@ -540,6 +540,16 @@ MutableSpan InstancesComponent::positions() return positions_; } +MutableSpan InstancesComponent::rotations() +{ + return rotations_; +} + +MutableSpan InstancesComponent::scales() +{ + return scales_; +} + int InstancesComponent::instances_amount() const { const int size = instanced_data_.size(); diff --git a/source/blender/nodes/geometry/nodes/node_geo_transform.cc b/source/blender/nodes/geometry/nodes/node_geo_transform.cc index abfa603b584..4fe61dff72d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_transform.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_transform.cc @@ -92,6 +92,8 @@ static void transform_instances(InstancesComponent &instances, const float3 scale) { MutableSpan positions = instances.positions(); + MutableSpan rotations = instances.rotations(); + MutableSpan scales = instances.scales(); /* Use only translation if rotation and scale don't apply. */ if (use_translate(rotation, scale)) { @@ -101,9 +103,15 @@ static void transform_instances(InstancesComponent &instances, } else { float mat[4][4]; + float instance_mat[4][4]; + float quaternion[4]; + loc_eul_size_to_mat4(mat, translation, rotation, scale); - for (float3 &position : positions) { - mul_m4_v3(mat, position); + for (int i = 0; i < positions.size(); i++) { + loc_eul_size_to_mat4(instance_mat, positions[i], rotations[i], scales[i]); + mul_m4_m4_post(instance_mat, mat); + mat4_decompose(positions[i], quaternion, scales[i], instance_mat); + quat_to_eul(rotations[i], quaternion); } } }