Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-02-20 16:22:40 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-02-22 02:55:32 +0300
commit2d81758aa650256d6b6ed283e43b6c35808ed205 (patch)
treedb336da6924982031bbcc30844b496d600fd407a /intern/cycles/kernel/closure
parent84e92f9b3c50433221a4c30f3a14713d99680f3a (diff)
Cycles: better path termination for transparency.
We now continue transparent paths after diffuse/glossy/transmission/volume bounces are exceeded. This avoids unexpected boundaries in volumes with transparent boundaries. It is also required for MIS to work correctly with transparent surfaces, as we also continue through these in shadow rays. The main visible changes is that volumes will now be lit by the background even at volume bounces 0, same as surfaces. Fixes T53914 and T54103.
Diffstat (limited to 'intern/cycles/kernel/closure')
-rw-r--r--intern/cycles/kernel/closure/bsdf_transparent.h29
1 files changed, 23 insertions, 6 deletions
diff --git a/intern/cycles/kernel/closure/bsdf_transparent.h b/intern/cycles/kernel/closure/bsdf_transparent.h
index 22ca7f3847e..79ee9dc4537 100644
--- a/intern/cycles/kernel/closure/bsdf_transparent.h
+++ b/intern/cycles/kernel/closure/bsdf_transparent.h
@@ -35,21 +35,38 @@
CCL_NAMESPACE_BEGIN
-ccl_device void bsdf_transparent_setup(ShaderData *sd, const float3 weight)
+ccl_device void bsdf_transparent_setup(ShaderData *sd, const float3 weight, int path_flag)
{
if(sd->flag & SD_TRANSPARENT) {
sd->closure_transparent_extinction += weight;
+
+ 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));
+ break;
+ }
+ }
}
else {
sd->flag |= SD_BSDF|SD_TRANSPARENT;
sd->closure_transparent_extinction = weight;
- }
- ShaderClosure *bsdf = bsdf_alloc(sd, sizeof(ShaderClosure), weight);
+ if(path_flag & PATH_RAY_TERMINATE) {
+ /* In this case the number of closures is set to zero to disable
+ * all others, but we still want to get transparency so increase
+ * the number just for this. */
+ sd->num_closure_left = 1;
+ }
+
+ ShaderClosure *bsdf = bsdf_alloc(sd, sizeof(ShaderClosure), weight);
- if(bsdf) {
- bsdf->N = sd->N;
- bsdf->type = CLOSURE_BSDF_TRANSPARENT_ID;
+ if(bsdf) {
+ bsdf->N = sd->N;
+ bsdf->type = CLOSURE_BSDF_TRANSPARENT_ID;
+ }
}
}