Cycles: Fix wrong original ray used for SSS baking

Also de-duplicated some code by moving to an utility function.
This commit is contained in:
Sergey Sharybin 2015-11-28 19:43:54 +05:00
parent 1e43f0d742
commit f5d1551b6e
2 changed files with 11 additions and 5 deletions

@ -65,8 +65,8 @@ ccl_device void compute_light_pass(KernelGlobals *kg, ShaderData *sd, PathRadian
if((is_combined || is_sss_sample) && (sd->flag & SD_BSSRDF)) {
/* when mixing BSSRDF and BSDF closures we should skip BSDF lighting if scattering was successful */
SubsurfaceIndirectRays ss_indirect;
ss_indirect.tracing = false;
ss_indirect.num_rays = 0;
Ray orig_ray = ray;
kernel_path_subsurface_init_indirect(&ss_indirect);
if(kernel_path_subsurface_scatter(kg,
sd,
&L_sample,
@ -79,7 +79,7 @@ ccl_device void compute_light_pass(KernelGlobals *kg, ShaderData *sd, PathRadian
while(ss_indirect.num_rays) {
kernel_path_subsurface_setup_indirect(kg,
&ss_indirect,
&ray,
&orig_ray,
&state,
&ray,
&L_sample,

@ -522,6 +522,13 @@ ccl_device bool kernel_path_subsurface_scatter(
return false;
}
ccl_device_inline void kernel_path_subsurface_init_indirect(
SubsurfaceIndirectRays *ss_indirect)
{
ss_indirect->tracing = false;
ss_indirect->num_rays = 0;
}
ccl_device void kernel_path_subsurface_accum_indirect(
SubsurfaceIndirectRays *ss_indirect,
PathRadiance *L)
@ -598,8 +605,7 @@ ccl_device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample,
#ifdef __SUBSURFACE__
SubsurfaceIndirectRays ss_indirect;
ss_indirect.tracing = false;
ss_indirect.num_rays = 0;
kernel_path_subsurface_init_indirect(&ss_indirect);
/* TODO(sergey): Avoid having explicit copy of the pre-subsurface scatter
* ray by storing an updated version of state in the ss_indirect which will