Fix T40135: cycles baking did not support branched path settings yet.

This commit is contained in:
Brecht Van Lommel
2014-05-19 15:14:43 +02:00
parent 6252f75025
commit db2d900f74
2 changed files with 59 additions and 29 deletions

View File

@@ -45,19 +45,24 @@ ccl_device void compute_light_pass(KernelGlobals *kg, ShaderData *sd, PathRadian
/* TODO, disable the closures we won't need */
#ifdef __BRANCHED_PATH__
if(!kernel_data.integrator.branched) {
/* regular path tracer */
#endif
/* sample ambient occlusion */
if(is_combined || is_ao) {
kernel_path_ao(kg, sd, &L_sample, &state, &rng, throughput);
}
#ifdef __SUBSURFACE__
/* sample subsurface scattering */
if((is_combined || is_sss) && (sd->flag & SD_BSSRDF)) {
#ifdef __SUBSURFACE__
/* when mixing BSSRDF and BSDF closures we should skip BSDF lighting if scattering was successful */
if (kernel_path_subsurface_scatter(kg, sd, &L_sample, &state, &rng, &ray, &throughput))
is_sss = true;
#endif
}
#endif
/* sample light and BSDF */
if((!is_sss) && (!is_ao)) {
@@ -73,6 +78,31 @@ ccl_device void compute_light_pass(KernelGlobals *kg, ShaderData *sd, PathRadian
path_radiance_reset_indirect(&L_sample);
}
}
#ifdef __BRANCHED_PATH__
}
else {
/* branched path tracer */
/* sample ambient occlusion */
if(is_combined || is_ao) {
kernel_branched_path_ao(kg, sd, &L_sample, &state, &rng, throughput);
}
#ifdef __SUBSURFACE__
/* sample subsurface scattering */
if((is_combined || is_sss) && (sd->flag & SD_BSSRDF)) {
/* when mixing BSSRDF and BSDF closures we should skip BSDF lighting if scattering was successful */
kernel_branched_path_subsurface_scatter(kg, sd, &L_sample, &state, &rng, throughput);
}
#endif
/* sample light and BSDF */
if((!is_sss) && (!is_ao)) {
kernel_branched_path_integrate_lighting(kg, &rng,
sd, throughput, 1.0f, &state, &L_sample);
}
#endif
}
/* accumulate into master L */
path_radiance_accum_sample(L, &L_sample, samples);

View File

@@ -982,7 +982,7 @@ ccl_device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample,
ccl_device_noinline void kernel_branched_path_integrate_lighting(KernelGlobals *kg,
RNG *rng, ShaderData *sd, float3 throughput, float num_samples_adjust,
PathState *state, PathRadiance *L, ccl_global float *buffer)
PathState *state, PathRadiance *L)
{
#ifdef __EMISSION__
if(kernel_data.integrator.use_direct_light) {
@@ -1081,7 +1081,7 @@ ccl_device_noinline void kernel_branched_path_integrate_lighting(KernelGlobals *
}
#ifdef __SUBSURFACE__
ccl_device void kernel_branched_path_subsurface_scatter(KernelGlobals *kg, ShaderData *sd, PathRadiance *L, PathState *state, RNG *rng, float3 throughput, ccl_global float *buffer)
ccl_device void kernel_branched_path_subsurface_scatter(KernelGlobals *kg, ShaderData *sd, PathRadiance *L, PathState *state, RNG *rng, float3 throughput)
{
for(int i = 0; i< sd->num_closure; i++) {
ShaderClosure *sc = &sd->closure[i];
@@ -1113,7 +1113,7 @@ ccl_device void kernel_branched_path_subsurface_scatter(KernelGlobals *kg, Shade
kernel_branched_path_integrate_lighting(kg, rng,
&bssrdf_sd[hit], throughput, num_samples_inv,
&hit_state, L, buffer);
&hit_state, L);
}
}
@@ -1344,7 +1344,7 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
#ifdef __SUBSURFACE__
/* bssrdf scatter to a different location on the same object */
if(sd.flag & SD_BSSRDF) {
kernel_branched_path_subsurface_scatter(kg, &sd, &L, &state, rng, throughput, buffer);
kernel_branched_path_subsurface_scatter(kg, &sd, &L, &state, rng, throughput);
}
#endif
@@ -1353,7 +1353,7 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
/* lighting */
kernel_branched_path_integrate_lighting(kg, rng,
&sd, throughput, 1.0f, &hit_state, &L, buffer);
&sd, throughput, 1.0f, &hit_state, &L);
/* continue in case of transparency */
throughput *= shader_bsdf_transparency(kg, &sd);