Fix T40135: cycles baking did not support branched path settings yet.
This commit is contained in:
@@ -45,33 +45,63 @@ ccl_device void compute_light_pass(KernelGlobals *kg, ShaderData *sd, PathRadian
|
|||||||
|
|
||||||
/* TODO, disable the closures we won't need */
|
/* TODO, disable the closures we won't need */
|
||||||
|
|
||||||
/* sample ambient occlusion */
|
#ifdef __BRANCHED_PATH__
|
||||||
if(is_combined || is_ao) {
|
if(!kernel_data.integrator.branched) {
|
||||||
kernel_path_ao(kg, sd, &L_sample, &state, &rng, throughput);
|
/* regular path tracer */
|
||||||
}
|
|
||||||
|
|
||||||
/* 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 */
|
/* sample ambient occlusion */
|
||||||
if((!is_sss) && (!is_ao)) {
|
if(is_combined || is_ao) {
|
||||||
if(kernel_path_integrate_lighting(kg, &rng, sd, &throughput, &state, &L_sample, &ray)) {
|
kernel_path_ao(kg, sd, &L_sample, &state, &rng, throughput);
|
||||||
#ifdef __LAMP_MIS__
|
|
||||||
state.ray_t = 0.0f;
|
|
||||||
#endif
|
|
||||||
/* 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#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 */
|
||||||
|
if (kernel_path_subsurface_scatter(kg, sd, &L_sample, &state, &rng, &ray, &throughput))
|
||||||
|
is_sss = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* sample light and BSDF */
|
||||||
|
if((!is_sss) && (!is_ao)) {
|
||||||
|
if(kernel_path_integrate_lighting(kg, &rng, sd, &throughput, &state, &L_sample, &ray)) {
|
||||||
|
#ifdef __LAMP_MIS__
|
||||||
|
state.ray_t = 0.0f;
|
||||||
|
#endif
|
||||||
|
/* 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#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 */
|
/* accumulate into master L */
|
||||||
|
@@ -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,
|
ccl_device_noinline void kernel_branched_path_integrate_lighting(KernelGlobals *kg,
|
||||||
RNG *rng, ShaderData *sd, float3 throughput, float num_samples_adjust,
|
RNG *rng, ShaderData *sd, float3 throughput, float num_samples_adjust,
|
||||||
PathState *state, PathRadiance *L, ccl_global float *buffer)
|
PathState *state, PathRadiance *L)
|
||||||
{
|
{
|
||||||
#ifdef __EMISSION__
|
#ifdef __EMISSION__
|
||||||
if(kernel_data.integrator.use_direct_light) {
|
if(kernel_data.integrator.use_direct_light) {
|
||||||
@@ -1081,7 +1081,7 @@ ccl_device_noinline void kernel_branched_path_integrate_lighting(KernelGlobals *
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __SUBSURFACE__
|
#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++) {
|
for(int i = 0; i< sd->num_closure; i++) {
|
||||||
ShaderClosure *sc = &sd->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,
|
kernel_branched_path_integrate_lighting(kg, rng,
|
||||||
&bssrdf_sd[hit], throughput, num_samples_inv,
|
&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__
|
#ifdef __SUBSURFACE__
|
||||||
/* bssrdf scatter to a different location on the same object */
|
/* bssrdf scatter to a different location on the same object */
|
||||||
if(sd.flag & SD_BSSRDF) {
|
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
|
#endif
|
||||||
|
|
||||||
@@ -1353,7 +1353,7 @@ ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, in
|
|||||||
|
|
||||||
/* lighting */
|
/* lighting */
|
||||||
kernel_branched_path_integrate_lighting(kg, rng,
|
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 */
|
/* continue in case of transparency */
|
||||||
throughput *= shader_bsdf_transparency(kg, &sd);
|
throughput *= shader_bsdf_transparency(kg, &sd);
|
||||||
|
Reference in New Issue
Block a user