Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2021-10-07 18:27:22 +0300
committerBrecht Van Lommel <brecht@blender.org>2021-10-11 19:22:54 +0300
commit73a05ff9e83a31be34d32a92cd5fb4d17994e342 (patch)
tree06f0312affd92e58393216186f1519125a7c302c /intern/cycles/kernel/bvh
parent40360253aefd1f3451d5b413595bcbb143425b84 (diff)
Cycles: restore Christensen-Burley SSS
There is not enough time before the release to improve Random Walk to handle all cases this was used for, so restore it for now. Since there is no more path splitting in cycles-x, this can increase noise in non-flat areas for the sample number of samples, though fewer rays will be traced also. This is fundamentally a trade-off we made in the new design and why Random Walk is a better fit. However the importance resampling we do now does help to reduce noise. Differential Revision: https://developer.blender.org/D12800
Diffstat (limited to 'intern/cycles/kernel/bvh')
-rw-r--r--intern/cycles/kernel/bvh/bvh_util.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/intern/cycles/kernel/bvh/bvh_util.h b/intern/cycles/kernel/bvh/bvh_util.h
index 9f188a93e2c..e16da9755f2 100644
--- a/intern/cycles/kernel/bvh/bvh_util.h
+++ b/intern/cycles/kernel/bvh/bvh_util.h
@@ -113,6 +113,30 @@ ccl_device_inline void sort_intersections(Intersection *hits, uint num_hits)
}
#endif /* __SHADOW_RECORD_ALL__ | __VOLUME_RECORD_ALL__ */
+/* For subsurface scattering, only sorting a small amount of intersections
+ * so bubble sort is fine for CPU and GPU. */
+ccl_device_inline void sort_intersections_and_normals(Intersection *hits,
+ float3 *Ng,
+ uint num_hits)
+{
+ bool swapped;
+ do {
+ swapped = false;
+ for (int j = 0; j < num_hits - 1; ++j) {
+ if (hits[j].t > hits[j + 1].t) {
+ struct Intersection tmp_hit = hits[j];
+ struct float3 tmp_Ng = Ng[j];
+ hits[j] = hits[j + 1];
+ Ng[j] = Ng[j + 1];
+ hits[j + 1] = tmp_hit;
+ Ng[j + 1] = tmp_Ng;
+ swapped = true;
+ }
+ }
+ --num_hits;
+ } while (swapped);
+}
+
/* Utility to quickly get flags from an intersection. */
ccl_device_forceinline int intersection_get_shader_flags(const KernelGlobals *ccl_restrict kg,