diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-05-06 02:24:53 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-05-06 03:00:39 +0300 |
commit | 2dd0cb4964e854985e746d457756a72e8c872360 (patch) | |
tree | 45ef740668ec7b7af390c8184f80e715002d9309 /intern/cycles/kernel/closure/bsdf_transparent.h | |
parent | d3b3df037197d46b608eb38a5dbd6f1d2761ec36 (diff) |
Fix T54801: incorrect render with zero weight transparent BSDFs.
Diffstat (limited to 'intern/cycles/kernel/closure/bsdf_transparent.h')
-rw-r--r-- | intern/cycles/kernel/closure/bsdf_transparent.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/intern/cycles/kernel/closure/bsdf_transparent.h b/intern/cycles/kernel/closure/bsdf_transparent.h index 79ee9dc4537..8fc7ef4dd4f 100644 --- a/intern/cycles/kernel/closure/bsdf_transparent.h +++ b/intern/cycles/kernel/closure/bsdf_transparent.h @@ -37,15 +37,22 @@ CCL_NAMESPACE_BEGIN ccl_device void bsdf_transparent_setup(ShaderData *sd, const float3 weight, int path_flag) { + /* Check cutoff weight. */ + float sample_weight = fabsf(average(weight)); + if(!(sample_weight >= CLOSURE_WEIGHT_CUTOFF)) { + return; + } + if(sd->flag & SD_TRANSPARENT) { sd->closure_transparent_extinction += weight; + /* Add weight to existing transparent BSDF. */ for(int i = 0; i < sd->num_closure; i++) { ShaderClosure *sc = &sd->closure[i]; if(sc->type == CLOSURE_BSDF_TRANSPARENT_ID) { sc->weight += weight; - sc->sample_weight += fabsf(average(weight)); + sc->sample_weight += sample_weight; break; } } @@ -61,11 +68,15 @@ ccl_device void bsdf_transparent_setup(ShaderData *sd, const float3 weight, int sd->num_closure_left = 1; } - ShaderClosure *bsdf = bsdf_alloc(sd, sizeof(ShaderClosure), weight); + /* Create new transparent BSDF. */ + ShaderClosure *bsdf = closure_alloc(sd, sizeof(ShaderClosure), CLOSURE_BSDF_TRANSPARENT_ID, weight); if(bsdf) { + bsdf->sample_weight = sample_weight; bsdf->N = sd->N; - bsdf->type = CLOSURE_BSDF_TRANSPARENT_ID; + } + else if(path_flag & PATH_RAY_TERMINATE) { + sd->num_closure_left = 0; } } } |