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.
This commit is contained in:
Brecht Van Lommel
2013-07-08 23:31:45 +00:00
parent b2b6d56443
commit 3d847ed6e6
2 changed files with 37 additions and 1 deletions

View File

@@ -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;