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
path: root/intern
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2013-07-09 03:31:45 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-07-09 03:31:45 +0400
commit3d847ed6e6e0a063d1676ad9c01bcc33b23b8ac4 (patch)
tree3f8f85537a97bd3d63ac6917f41cd1a645c61c6f /intern
parentb2b6d564431db71e1c9176ca541a0dd9e7f91168 (diff)
Fix #36064: cycles direct/indirect light passes with materials that have zero
RGB color components gave non-grey results when you might no expect it. What happens is that some of the color channels are zero in the direct light pass because their channel is zero in the color pass. The direct light pass is defined as lighting divided by the color pass, and we can't divide by zero. We do a division after all samples are added together to ensure that multiplication in the compositor gives the exact combined pass even with antialiasing, DoF, .. Found a simple tweak here, instead of setting such channels to zero it will set it to the average of other non-zero color channels, which makes the results look like the expected grey.
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/render/buffers.cpp2
-rw-r--r--intern/cycles/util/util_math.h36
2 files changed, 37 insertions, 1 deletions
diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp
index 572cfae45cd..b509134512b 100644
--- a/intern/cycles/render/buffers.cpp
+++ b/intern/cycles/render/buffers.cpp
@@ -223,7 +223,7 @@ bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int
float3 f = make_float3(in[0], in[1], in[2]);
float3 f_divide = make_float3(in_divide[0], in_divide[1], in_divide[2]);
- f = safe_divide_color(f*exposure, f_divide);
+ f = safe_divide_even_color(f*exposure, f_divide);
pixels[0] = f.x;
pixels[1] = f.y;
diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h
index 14ebf311a4b..cde547cd77c 100644
--- a/intern/cycles/util/util_math.h
+++ b/intern/cycles/util/util_math.h
@@ -1100,6 +1100,42 @@ __device_inline float3 safe_divide_color(float3 a, float3 b)
return make_float3(x, y, z);
}
+__device_inline float3 safe_divide_even_color(float3 a, float3 b)
+{
+ float x, y, z;
+
+ x = (b.x != 0.0f)? a.x/b.x: 0.0f;
+ y = (b.y != 0.0f)? a.y/b.y: 0.0f;
+ z = (b.z != 0.0f)? a.z/b.z: 0.0f;
+
+ /* try to get grey even if b is zero */
+ if(b.x == 0.0f) {
+ if(b.y == 0.0f) {
+ x = z;
+ y = z;
+ }
+ else if(b.z == 0.0f) {
+ x = y;
+ z = y;
+ }
+ else
+ x = 0.5f*(y + z);
+ }
+ else if(b.y == 0.0f) {
+ if(b.z == 0.0f) {
+ y = x;
+ z = x;
+ }
+ else
+ y = 0.5f*(x + z);
+ }
+ else if(b.z == 0.0f) {
+ z = 0.5f*(x + y);
+ }
+
+ return make_float3(x, y, z);
+}
+
/* Rotation of point around axis and angle */
__device_inline float3 rotate_around_axis(float3 p, float3 axis, float angle)