From b9ebd96539f9eb54c2005cdddff144546cc0782a Mon Sep 17 00:00:00 2001 From: Alaska Date: Tue, 21 Jan 2025 04:31:43 +0100 Subject: [PATCH] Fix #133229: Remove camera size optimization from SSS shader in Cycles In Cycles, the subsurface scattering shader will switch to a diffuse shader under a few different conditions to improve performance and reduce noise. This commit removes the "switch back to diffuse if the scattering radius is less than a quarter of a pixel" optimization because in some scenes, this can result in noticable lines as the shader transitions between subsurface scattering and diffuse. Pull Request: https://projects.blender.org/blender/blender/pulls/133245 --- intern/cycles/kernel/closure/bssrdf.h | 22 +++++++++++----------- tests/data | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/intern/cycles/kernel/closure/bssrdf.h b/intern/cycles/kernel/closure/bssrdf.h index 6abe1f79e71..2c791f0e526 100644 --- a/intern/cycles/kernel/closure/bssrdf.h +++ b/intern/cycles/kernel/closure/bssrdf.h @@ -305,20 +305,20 @@ ccl_device int bssrdf_setup(ccl_private ShaderData *sd, int bssrdf_channels = SPECTRUM_CHANNELS; Spectrum diffuse_weight = zero_spectrum(); - /* Fall back to diffuse if the radius is smaller than a quarter pixel. */ - float min_radius = max(0.25f * sd->dP, BSSRDF_MIN_RADIUS); if (path_flag & PATH_RAY_DIFFUSE_ANCESTOR) { - /* Always fall back to diffuse after a diffuse ancestor. Can't see it well then and adds + /* Always fall back to diffuse after a diffuse ancestor. Can't see it that well and it adds * considerable noise due to probabilities of continuing the path getting lower and lower. */ - min_radius = FLT_MAX; + bssrdf_channels = 0; + diffuse_weight = bssrdf->weight; } - - FOREACH_SPECTRUM_CHANNEL (i) { - if (GET_SPECTRUM_CHANNEL(bssrdf->radius, i) < min_radius) { - GET_SPECTRUM_CHANNEL(diffuse_weight, i) = GET_SPECTRUM_CHANNEL(bssrdf->weight, i); - GET_SPECTRUM_CHANNEL(bssrdf->weight, i) = 0.0f; - GET_SPECTRUM_CHANNEL(bssrdf->radius, i) = 0.0f; - bssrdf_channels--; + else { + FOREACH_SPECTRUM_CHANNEL (i) { + if (GET_SPECTRUM_CHANNEL(bssrdf->radius, i) < BSSRDF_MIN_RADIUS) { + GET_SPECTRUM_CHANNEL(diffuse_weight, i) = GET_SPECTRUM_CHANNEL(bssrdf->weight, i); + GET_SPECTRUM_CHANNEL(bssrdf->weight, i) = 0.0f; + GET_SPECTRUM_CHANNEL(bssrdf->radius, i) = 0.0f; + bssrdf_channels--; + } } } diff --git a/tests/data b/tests/data index 2e9d939dd2d..c94e0deff0d 160000 --- a/tests/data +++ b/tests/data @@ -1 +1 @@ -Subproject commit 2e9d939dd2d8ec017888c497742c1f138755f189 +Subproject commit c94e0deff0da1742c9afc2cff9b896b6465737df