diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-11-28 17:30:35 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-11-28 18:07:34 +0300 |
commit | 1e43f0d74216cc936e6a708be321ba2c05b66ca1 (patch) | |
tree | 203cfcc239df6543980580c12c70773073e37f0d /intern/cycles/kernel/kernel_bake.h | |
parent | 8919ed3a62137259f5c94d7ebd7cfdce452371b8 (diff) |
Cycles: Set of fixes for delayed SSS ray tracing
There were multiple issues which are solved now:
- It was possible that ray wouldn't be bounced off the BSSRDF, for example
when PDF or shader eval is zero. In this case PathState might have been
left in pre-bounced state which would have been gave incorrect shading
results.
This is solved by having separate PathState for each of the hits.
- Path radiance summing wasn't happening correct as well, indirect rays
were using wrong path radiance in the case when there were more than
one hit recorded.
This is now using a bit trickier state machine which calculates path
radiance for just SSS (both direct and indirect) and then sums it back
to the final radiance.
- Previous commit wasn't totally correct either and was an induced bug
due to wrong path state left from the "un-happened" ray bounce.
There should be no special case happening here, BSSRDFs will be replaced
with diffuse ones due to PATH_RAY_DIFFUSE_ANCESTOR flag.
- Merged back codebases for "delayed" and "immediate" indirect SSS ray
tracing, hopefully making it easier to maintain the codebase.
Sure this changes brings memory usage back by about 4-5%, but overall
it's still about 2x memory reduction for the experimental kernel here.
Thanks Brecht for the review!
Diffstat (limited to 'intern/cycles/kernel/kernel_bake.h')
-rw-r--r-- | intern/cycles/kernel/kernel_bake.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/intern/cycles/kernel/kernel_bake.h b/intern/cycles/kernel/kernel_bake.h index 57cbf0b63db..a04e759f6eb 100644 --- a/intern/cycles/kernel/kernel_bake.h +++ b/intern/cycles/kernel/kernel_bake.h @@ -65,6 +65,7 @@ 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; if(kernel_path_subsurface_scatter(kg, sd, @@ -75,14 +76,13 @@ ccl_device void compute_light_pass(KernelGlobals *kg, ShaderData *sd, PathRadian &throughput, &ss_indirect)) { -# ifdef __SUBSURFACE_DELAYED_INDIRECT__ while(ss_indirect.num_rays) { kernel_path_subsurface_setup_indirect(kg, &ss_indirect, - &L_sample, - &state, &ray, + &state, &ray, + &L_sample, &throughput); kernel_path_indirect(kg, &rng, @@ -91,8 +91,8 @@ ccl_device void compute_light_pass(KernelGlobals *kg, ShaderData *sd, PathRadian state.num_samples, &state, &L_sample); + kernel_path_subsurface_accum_indirect(&ss_indirect, &L_sample); } -# endif /* __SUBSURFACE_DELAYED_INDIRECT__ */ is_sss_sample = true; } } |