diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-03-01 01:00:46 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-03-01 03:21:29 +0300 |
commit | 7f86afec9d6799e22127c53d9d0805a87462fc08 (patch) | |
tree | 566aca7a18e47b45251b10fcb5b4393c0d3562a8 /intern/cycles/kernel/kernel_path_branched.h | |
parent | 03d10703783a0d233517aac558ac3f0a7d55d302 (diff) |
Cycles: don't count volume boundaries as transparent bounces.
This is more important now that we will have tigther volume bounds that
we hit multiple times. It also avoids some noise due to RR previously
affecting these surfaces, which shouldn't have been the case and should
eventually be fixed for transparent BSDFs as well.
For non-volume scenes I found no performance impact on NVIDIA or AMD.
For volume scenes the noise decrease and fixed artifacts are worth the
little extra render time, when there is any.
Diffstat (limited to 'intern/cycles/kernel/kernel_path_branched.h')
-rw-r--r-- | intern/cycles/kernel/kernel_path_branched.h | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/intern/cycles/kernel/kernel_path_branched.h b/intern/cycles/kernel/kernel_path_branched.h index 441a06eeba3..d43d418db29 100644 --- a/intern/cycles/kernel/kernel_path_branched.h +++ b/intern/cycles/kernel/kernel_path_branched.h @@ -480,6 +480,12 @@ ccl_device void kernel_branched_path_integrate(KernelGlobals *kg, /* Setup and evaluate shader. */ shader_setup_from_ray(kg, &sd, &isect, &ray); + + /* Skip most work for volume bounding surface. */ +#ifdef __VOLUME__ + if(!(sd.flag & SD_HAS_ONLY_VOLUME)) { +#endif + shader_eval_surface(kg, &sd, &state, state.flag); shader_merge_closures(&sd); @@ -533,37 +539,46 @@ ccl_device void kernel_branched_path_integrate(KernelGlobals *kg, } #endif /* __SUBSURFACE__ */ - if(!(sd.flag & SD_HAS_ONLY_VOLUME)) { - PathState hit_state = state; + PathState hit_state = state; #ifdef __EMISSION__ - /* direct light */ - if(kernel_data.integrator.use_direct_light) { - int all = (kernel_data.integrator.sample_all_lights_direct) || - (state.flag & PATH_RAY_SHADOW_CATCHER); - kernel_branched_path_surface_connect_light(kg, - &sd, emission_sd, &hit_state, throughput, 1.0f, L, all); - } + /* direct light */ + if(kernel_data.integrator.use_direct_light) { + int all = (kernel_data.integrator.sample_all_lights_direct) || + (state.flag & PATH_RAY_SHADOW_CATCHER); + kernel_branched_path_surface_connect_light(kg, + &sd, emission_sd, &hit_state, throughput, 1.0f, L, all); + } #endif /* __EMISSION__ */ - /* indirect light */ - kernel_branched_path_surface_indirect_light(kg, - &sd, &indirect_sd, emission_sd, throughput, 1.0f, &hit_state, L); + /* indirect light */ + kernel_branched_path_surface_indirect_light(kg, + &sd, &indirect_sd, emission_sd, throughput, 1.0f, &hit_state, L); - /* continue in case of transparency */ - throughput *= shader_bsdf_transparency(kg, &sd); + /* continue in case of transparency */ + throughput *= shader_bsdf_transparency(kg, &sd); - if(is_zero(throughput)) - break; - } + if(is_zero(throughput)) + break; /* Update Path State */ path_state_next(kg, &state, LABEL_TRANSPARENT); +#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) { + break; + } + } +#endif + ray.P = ray_offset(sd.P, -sd.Ng); ray.t -= sd.ray_length; /* clipping works through transparent */ - #ifdef __RAY_DIFFERENTIALS__ ray.dP = sd.dP; ray.dD.dx = -sd.dI.dx; |