diff options
author | Brecht Van Lommel <brecht@blender.org> | 2021-04-15 17:21:37 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2021-04-19 22:07:40 +0300 |
commit | d1fbf1599fd445955596b69e327d30710e50724e (patch) | |
tree | 27a36f59a03ea68e917a617a88c37e94c27ffb39 /intern/cycles | |
parent | b42454be8bf08381a4c3578e6a4bdfaec0471586 (diff) |
Cycles: include more transparency and emission in fast GI approximation
For indirect light rays, don't assume any hit is opaque, rather if it has
transparency or emission do the shading but don't do any further bounces.
Naturally this is slower when there are transparent surfaces, however
without this cutout opacity doesn't give sensible results.
Differential Revision: https://developer.blender.org/D10985
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/kernel/kernel_path.h | 17 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_types.h | 2 | ||||
-rw-r--r-- | intern/cycles/render/shader.cpp | 2 |
3 files changed, 18 insertions, 3 deletions
diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h index 5681510fc25..dd2390808ea 100644 --- a/intern/cycles/kernel/kernel_path.h +++ b/intern/cycles/kernel/kernel_path.h @@ -65,7 +65,6 @@ ccl_device_forceinline bool kernel_path_scene_intersect(KernelGlobals *kg, uint visibility = path_state_ray_visibility(kg, state); if (path_state_ao_bounce(kg, state)) { - visibility = PATH_RAY_SHADOW; ray->t = kernel_data.background.ao_distance; } @@ -416,7 +415,13 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg, break; } else if (path_state_ao_bounce(kg, state)) { - break; + if (intersection_get_shader_flags(kg, &isect) & + (SD_HAS_TRANSPARENT_SHADOW | SD_HAS_EMISSION)) { + state->flag |= PATH_RAY_TERMINATE_AFTER_TRANSPARENT; + } + else { + break; + } } /* Setup shader data. */ @@ -554,7 +559,13 @@ ccl_device_forceinline void kernel_path_integrate(KernelGlobals *kg, break; } else if (path_state_ao_bounce(kg, state)) { - break; + if (intersection_get_shader_flags(kg, &isect) & + (SD_HAS_TRANSPARENT_SHADOW | SD_HAS_EMISSION)) { + state->flag |= PATH_RAY_TERMINATE_AFTER_TRANSPARENT; + } + else { + break; + } } /* Setup shader data. */ diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index ab54fda14af..18c4d2f86ad 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -895,6 +895,8 @@ enum ShaderDataFlag { SD_HAS_CONSTANT_EMISSION = (1 << 27), /* Needs to access attributes for volume rendering */ SD_NEED_VOLUME_ATTRIBUTES = (1 << 28), + /* Shader has emission */ + SD_HAS_EMISSION = (1 << 29), SD_SHADER_FLAGS = (SD_USE_MIS | SD_HAS_TRANSPARENT_SHADOW | SD_HAS_VOLUME | SD_HAS_ONLY_VOLUME | SD_HETEROGENEOUS_VOLUME | SD_HAS_BSSRDF_BUMP | SD_VOLUME_EQUIANGULAR | diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp index 5ecbd92d96d..44a48cd2839 100644 --- a/intern/cycles/render/shader.cpp +++ b/intern/cycles/render/shader.cpp @@ -528,6 +528,8 @@ void ShaderManager::device_update_common(Device *device, if (shader->get_use_mis()) flag |= SD_USE_MIS; + if (shader->has_surface_emission) + flag |= SD_HAS_EMISSION; if (shader->has_surface_transparent && shader->get_use_transparent_shadow()) flag |= SD_HAS_TRANSPARENT_SHADOW; if (shader->has_volume) { |