Fix use of uninitialized memory in Cycles normal baking.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 3 Oct 2017 22:28:32 +0000 (00:28 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 4 Oct 2017 19:11:14 +0000 (21:11 +0200)
intern/cycles/kernel/kernel_bake.h

index 4d89839c46c81f28022fca52c0f826c292fcc20d..0d10e17a5936d98008563ff08b24513dc4c51a29 100644 (file)
@@ -335,12 +335,14 @@ ccl_device void kernel_bake_evaluate(KernelGlobals *kg, ccl_global uint4 *input,
                /* data passes */
                case SHADER_EVAL_NORMAL:
                {
+                       float3 N = sd.N;
                        if((sd.flag & SD_HAS_BUMP)) {
                                shader_eval_surface(kg, &sd, &state, 0);
+                               N = shader_bsdf_average_normal(kg, &sd);
                        }
 
                        /* encoding: normal = (2 * color) - 1 */
-                       out = shader_bsdf_average_normal(kg, &sd) * 0.5f + make_float3(0.5f, 0.5f, 0.5f);
+                       out = N * 0.5f + make_float3(0.5f, 0.5f, 0.5f);
                        break;
                }
                case SHADER_EVAL_UV: