Cycles: Fallback to diffuse BSDF for the indirect SSS rays when BSSRDF is hit

This is actually how it was intended to work, just didn't notice it wasn't
really happening in the main ray loop.

Solves some memory issues reported in T46880.
This commit is contained in:
Sergey Sharybin 2015-11-28 15:38:12 +05:00
parent 299fae1838
commit 8919ed3a62
1 changed files with 14 additions and 6 deletions

View File

@ -448,14 +448,22 @@ ccl_device bool kernel_path_subsurface_scatter(
/* do bssrdf scatter step if we picked a bssrdf closure */
if(sc) {
/* We should never have two consecutive BSSRDF bounces,
* the second one should be converted to a diffuse BSDF to
* avoid this.
*/
kernel_assert(ss_indirect->num_rays == 0);
uint lcg_state = lcg_state_init(rng, state, 0x68bc21eb);
/* If indirect ray hits BSSRDF we replace it with diffuse BSDF. */
if(ss_indirect->num_rays) {
float bssrdf_u, bssrdf_v;
path_state_rng_2D(kg, rng, state, PRNG_BSDF_U, &bssrdf_u, &bssrdf_v);
subsurface_scatter_step(kg,
sd,
state->flag,
sc,
&lcg_state,
bssrdf_u, bssrdf_v,
false);
return false;
}
SubsurfaceIntersection ss_isect;
float bssrdf_u, bssrdf_v;
path_state_rng_2D(kg, rng, state, PRNG_BSDF_U, &bssrdf_u, &bssrdf_v);