Fix T54317: overlapping volume render bug after recent changes.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 19 Mar 2018 19:20:01 +0000 (20:20 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 19 Mar 2018 20:22:15 +0000 (21:22 +0100)
Increasing the samplig dimensions like this is not optimal, I'm looking
into some deeper changes to reuse the random number and change the RR
probabilities, but this should fix the bug for now.

intern/cycles/kernel/kernel_path_branched.h
intern/cycles/kernel/kernel_path_state.h
intern/cycles/kernel/kernel_path_surface.h
intern/cycles/kernel/split/kernel_next_iteration_setup.h
intern/cycles/render/integrator.cpp

index d43d418..66f67c3 100644 (file)
@@ -567,10 +567,7 @@ ccl_device void kernel_branched_path_integrate(KernelGlobals *kg,
 #ifdef __VOLUME__
                }
                else {
-                       /* For volume bounding meshes we pass through without counting transparent
-                        * bounces, only sanity check in case self intersection gets us stuck. */
-                       state.volume_bounds_bounce++;
-                       if (state.volume_bounds_bounce > VOLUME_BOUNDS_MAX) {
+                       if(!path_state_volume_next(kg, &state)) {
                                break;
                        }
                }
index ff7d130..90937db 100644 (file)
@@ -166,6 +166,23 @@ ccl_device_inline void path_state_next(KernelGlobals *kg, ccl_addr_space PathSta
 #endif
 }
 
+ccl_device_inline bool path_state_volume_next(KernelGlobals *kg, ccl_addr_space PathState *state)
+{
+       /* For volume bounding meshes we pass through without counting transparent
+        * bounces, only sanity check in case self intersection gets us stuck. */
+       state->volume_bounds_bounce++;
+       if (state->volume_bounds_bounce > VOLUME_BOUNDS_MAX) {
+               return false;
+       }
+
+       /* Random number generator next bounce. */
+       if(state->volume_bounds_bounce > 1) {
+               state->rng_offset += PRNG_BOUNCE_NUM;
+       }
+
+       return true;
+}
+
 ccl_device_inline uint path_state_ray_visibility(KernelGlobals *kg, ccl_addr_space PathState *state)
 {
        uint flag = state->flag & PATH_RAY_ALL_VISIBILITY;
index bca346d..27be90d 100644 (file)
@@ -329,10 +329,7 @@ ccl_device bool kernel_path_surface_bounce(KernelGlobals *kg,
        }
 #ifdef __VOLUME__
        else if(sd->flag & SD_HAS_ONLY_VOLUME) {
-               /* For volume bounding meshes we pass through without counting transparent
-                * bounces, only sanity check in case self intersection gets us stuck. */
-               state->volume_bounds_bounce++;
-               if (state->volume_bounds_bounce > VOLUME_BOUNDS_MAX) {
+               if(!path_state_volume_next(kg, state)) {
                        return false;
                }
 
index 8092419..e388955 100644 (file)
@@ -76,10 +76,7 @@ ccl_device void kernel_split_branched_transparent_bounce(KernelGlobals *kg, int
 #  ifdef __VOLUME__
        }
        else {
-               /* For volume bounding meshes we pass through without counting transparent
-                * bounces, only sanity check in case self intersection gets us stuck. */
-               state->volume_bounds_bounce++;
-               if (state->volume_bounds_bounce > VOLUME_BOUNDS_MAX) {
+               if(!path_state_volume_next(kg, state)) {
                        kernel_split_path_end(kg, ray_index);
                        return;
                }
index c337c19..9c276bc 100644 (file)
@@ -187,7 +187,9 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene
                max_samples = max(max_samples, volume_samples);
        }
 
-       uint total_bounces = max_bounce + transparent_max_bounce + 3 +
+       uint total_bounces = max_bounce +
+                            transparent_max_bounce + 3 +
+                            VOLUME_BOUNDS_MAX +
                             max(BSSRDF_MAX_HITS, BSSRDF_MAX_BOUNCES);
 
        max_samples *= total_bounces;