From 08bf531956b1c1cff3319d119e8aba55b7a09b9e Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Wed, 7 May 2014 10:17:56 -0300 Subject: [PATCH] Cycles-Bake: Ambient Occlusion needs to be computed for COMBINED Now the COMBINED pass includes the Ambient Occlusion. This was not reported anywhere, but while working in the Subsurface Scattering I realize we needed this fix for combined. --- intern/cycles/kernel/kernel_displace.h | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/intern/cycles/kernel/kernel_displace.h b/intern/cycles/kernel/kernel_displace.h index 465d4dd4da6..012f399ca50 100644 --- a/intern/cycles/kernel/kernel_displace.h +++ b/intern/cycles/kernel/kernel_displace.h @@ -16,7 +16,8 @@ CCL_NAMESPACE_BEGIN -ccl_device void compute_light_pass(KernelGlobals *kg, ShaderData *sd, PathRadiance *L, RNG rng, bool is_ao) +ccl_device void compute_light_pass(KernelGlobals *kg, ShaderData *sd, PathRadiance *L, RNG rng, + bool is_combined, bool is_ao) { int samples = kernel_data.integrator.aa_samples; @@ -45,22 +46,24 @@ ccl_device void compute_light_pass(KernelGlobals *kg, ShaderData *sd, PathRadian /* TODO, disable the closures we won't need */ /* sample ambient occlusion */ - if(is_ao) { + if(is_combined || is_ao) { kernel_path_ao(kg, sd, &L_sample, &state, &rng, throughput); } /* sample light and BSDF */ - else if(kernel_path_integrate_lighting(kg, &rng, sd, &throughput, &state, &L_sample, &ray)) { + if(!is_ao) { + if(kernel_path_integrate_lighting(kg, &rng, sd, &throughput, &state, &L_sample, &ray)) { #ifdef __LAMP_MIS__ - state.ray_t = 0.0f; + state.ray_t = 0.0f; #endif - /* compute indirect light */ - kernel_path_indirect(kg, &rng, ray, throughput, state.num_samples, state, &L_sample); + /* compute indirect light */ + kernel_path_indirect(kg, &rng, ray, throughput, state.num_samples, state, &L_sample); - /* sum and reset indirect light pass variables for the next samples */ - path_radiance_sum_indirect(&L_sample); - path_radiance_reset_indirect(&L_sample); + /* sum and reset indirect light pass variables for the next samples */ + path_radiance_sum_indirect(&L_sample); + path_radiance_reset_indirect(&L_sample); + } } /* accumulate into master L */ @@ -123,7 +126,8 @@ ccl_device void kernel_bake_evaluate(KernelGlobals *kg, ccl_global uint4 *input, if(is_light_pass(type)) { RNG rng = cmj_hash(i, 0); - compute_light_pass(kg, &sd, &L, rng, (type == SHADER_EVAL_AO)); + compute_light_pass(kg, &sd, &L, rng, (type == SHADER_EVAL_COMBINED), + (type == SHADER_EVAL_AO)); } switch (type) {