[Bf-blender-cvs] [ffb9577ac9a] master: Cycles: Ensure finite displacement and background evaluation
Sergey Sharybin
noreply at git.blender.org
Wed Sep 29 14:06:24 CEST 2021
Commit: ffb9577ac9a4c79483941389a052284b64930c8e
Author: Sergey Sharybin
Date: Wed Sep 29 12:46:32 2021 +0200
Branches: master
https://developer.blender.org/rBffb9577ac9a4c79483941389a052284b64930c8e
Cycles: Ensure finite displacement and background evaluation
Avoids possible numerical issues in the path tracing kernel, which
is most important for displacement as non-finite values in BVH can
lead to infinite node recursion during traversal.
Differential Revision: https://developer.blender.org/D12690
===================================================================
M intern/cycles/kernel/kernel_bake.h
===================================================================
diff --git a/intern/cycles/kernel/kernel_bake.h b/intern/cycles/kernel/kernel_bake.h
index e025bcd6674..abb1ba455e6 100644
--- a/intern/cycles/kernel/kernel_bake.h
+++ b/intern/cycles/kernel/kernel_bake.h
@@ -42,6 +42,16 @@ ccl_device void kernel_displace_evaluate(const KernelGlobals *kg,
object_inverse_dir_transform(kg, &sd, &D);
+#ifdef __KERNEL_DEBUG_NAN__
+ if (!isfinite3_safe(D)) {
+ kernel_assert(!"Cycles displacement with non-finite value detected");
+ }
+#endif
+
+ /* Ensure finite displacement, preventing BVH from becoming degenerate and avoiding possible
+ * traversal issues caused by non-finite math. */
+ D = ensure_finite3(D);
+
/* Write output. */
output[offset] += make_float4(D.x, D.y, D.z, 0.0f);
}
@@ -66,7 +76,16 @@ ccl_device void kernel_background_evaluate(const KernelGlobals *kg,
const int path_flag = PATH_RAY_EMISSION;
shader_eval_surface<KERNEL_FEATURE_NODE_MASK_SURFACE_LIGHT>(
INTEGRATOR_STATE_PASS_NULL, &sd, NULL, path_flag);
- const float3 color = shader_background_eval(&sd);
+ float3 color = shader_background_eval(&sd);
+
+#ifdef __KERNEL_DEBUG_NAN__
+ if (!isfinite3_safe(color)) {
+ kernel_assert(!"Cycles background with non-finite value detected");
+ }
+#endif
+
+ /* Ensure finite color, avoiding possible numerical instabilities in the path tracing kernels. */
+ color = ensure_finite3(color);
/* Write output. */
output[offset] += make_float4(color.x, color.y, color.z, 0.0f);
More information about the Bf-blender-cvs
mailing list