Fix T40135: cycles baking did not support branched path settings yet.
This commit is contained in:
parent
6252f75025
commit
db2d900f74
Notes:
blender-bot
2023-02-14 10:40:10 +01:00
Referenced by issue #40262, Bake crash if you set GPU Referenced by issue #40135, Cycles Baking - Branched path tracing sample values have no effect
|
@ -45,33 +45,63 @@ ccl_device void compute_light_pass(KernelGlobals *kg, ShaderData *sd, PathRadian
|
|||
|
||||
/* TODO, disable the closures we won't need */
|
||||
|
||||
/* sample ambient occlusion */
|
||||
if(is_combined || is_ao) {
|
||||
kernel_path_ao(kg, sd, &L_sample, &state, &rng, throughput);
|
||||
}
|
||||
|
||||
/* 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;
|
||||
#ifdef __BRANCHED_PATH__
|
||||
if(!kernel_data.integrator.branched) {
|
||||
/* regular path tracer */
|
||||
#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);
|
||||
/* 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)) {
|
||||
/* 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 */
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue