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:
authorLukas Stockner <lukas.stockner@freenet.de>2019-05-31 23:38:50 +0300
committerLukas Stockner <lukas.stockner@freenet.de>2019-06-01 01:45:03 +0300
commitcc600de6695a241dd9b0de275656b5a7459552dc (patch)
tree6111f7469b75ae24a4a93a8109af3c3d233db722 /intern/cycles/util
parentd5b813301a81a7ec13996dfcb3a9bc88f56e4018 (diff)
Cycles Denoising: Get rid of halos around bright edges
Previously, bright edges (e.g. caused by rim lighting) would sometimes get halos around them after denoising. This change introduces a log(1+x) highlight compression step that is performed before denoising and reversed afterwards. That way, the denoising algorithm itself operates in the compressed space and therefore bright edges cause less numerical issues.
Diffstat (limited to 'intern/cycles/util')
-rw-r--r--intern/cycles/util/util_color.h14
-rw-r--r--intern/cycles/util/util_math_float3.h6
2 files changed, 20 insertions, 0 deletions
diff --git a/intern/cycles/util/util_color.h b/intern/cycles/util/util_color.h
index 83410db13c6..6e61190de6b 100644
--- a/intern/cycles/util/util_color.h
+++ b/intern/cycles/util/util_color.h
@@ -257,6 +257,20 @@ ccl_device float4 color_srgb_to_linear_v4(float4 c)
#endif
}
+ccl_device float3 color_highlight_compress(float3 color, float3 *variance)
+{
+ color += make_float3(1.0f, 1.0f, 1.0f);
+ if (variance) {
+ *variance *= sqr3(make_float3(1.0f, 1.0f, 1.0f) / color);
+ }
+ return log3(color);
+}
+
+ccl_device float3 color_highlight_uncompress(float3 color)
+{
+ return exp3(color) - make_float3(1.0f, 1.0f, 1.0f);
+}
+
CCL_NAMESPACE_END
#endif /* __UTIL_COLOR_H__ */
diff --git a/intern/cycles/util/util_math_float3.h b/intern/cycles/util/util_math_float3.h
index 85e9b8114ff..554b7408148 100644
--- a/intern/cycles/util/util_math_float3.h
+++ b/intern/cycles/util/util_math_float3.h
@@ -70,6 +70,7 @@ ccl_device_inline float3 safe_normalize(const float3 a);
ccl_device_inline float3 normalize_len(const float3 a, float *t);
ccl_device_inline float3 safe_normalize_len(const float3 a, float *t);
ccl_device_inline float3 interp(float3 a, float3 b, float t);
+ccl_device_inline float3 sqr3(float3 a);
ccl_device_inline bool is_zero(const float3 a);
ccl_device_inline float reduce_add(const float3 a);
@@ -349,6 +350,11 @@ ccl_device_inline float3 interp(float3 a, float3 b, float t)
return a + t * (b - a);
}
+ccl_device_inline float3 sqr3(float3 a)
+{
+ return a * a;
+}
+
ccl_device_inline bool is_zero(const float3 a)
{
#ifdef __KERNEL_SSE__