diff options
Diffstat (limited to 'intern/cycles/kernel')
-rw-r--r-- | intern/cycles/kernel/integrator/shade_surface.h | 2 | ||||
-rw-r--r-- | intern/cycles/kernel/integrator/shader_eval.h | 39 | ||||
-rw-r--r-- | intern/cycles/kernel/types.h | 14 |
3 files changed, 53 insertions, 2 deletions
diff --git a/intern/cycles/kernel/integrator/shade_surface.h b/intern/cycles/kernel/integrator/shade_surface.h index 3c84dcc3728..16a61c15f58 100644 --- a/intern/cycles/kernel/integrator/shade_surface.h +++ b/intern/cycles/kernel/integrator/shade_surface.h @@ -445,7 +445,7 @@ ccl_device bool integrate_surface(KernelGlobals kg, } #endif - shader_prepare_surface_closures(kg, state, &sd); + shader_prepare_surface_closures(kg, state, &sd, path_flag); #ifdef __HOLDOUT__ /* Evaluate holdout. */ diff --git a/intern/cycles/kernel/integrator/shader_eval.h b/intern/cycles/kernel/integrator/shader_eval.h index 68f1ef8c118..2560b71dc32 100644 --- a/intern/cycles/kernel/integrator/shader_eval.h +++ b/intern/cycles/kernel/integrator/shader_eval.h @@ -105,8 +105,45 @@ ccl_device_inline void shader_copy_volume_phases(ccl_private ShaderVolumePhases ccl_device_inline void shader_prepare_surface_closures(KernelGlobals kg, ConstIntegratorState state, - ccl_private ShaderData *sd) + ccl_private ShaderData *sd, + const uint32_t path_flag) { + /* Filter out closures. */ + if (kernel_data.integrator.filter_closures) { + if (kernel_data.integrator.filter_closures & FILTER_CLOSURE_EMISSION) { + sd->closure_emission_background = zero_float3(); + } + + if (kernel_data.integrator.filter_closures & FILTER_CLOSURE_DIRECT_LIGHT) { + sd->flag &= ~SD_BSDF_HAS_EVAL; + } + + if (path_flag & PATH_RAY_CAMERA) { + for (int i = 0; i < sd->num_closure; i++) { + ccl_private ShaderClosure *sc = &sd->closure[i]; + + if (CLOSURE_IS_BSDF_DIFFUSE(sc->type)) { + if (kernel_data.integrator.filter_closures & FILTER_CLOSURE_DIFFUSE) { + sc->type = CLOSURE_NONE_ID; + sc->sample_weight = 0.0f; + } + } + else if (CLOSURE_IS_BSDF_GLOSSY(sc->type)) { + if (kernel_data.integrator.filter_closures & FILTER_CLOSURE_GLOSSY) { + sc->type = CLOSURE_NONE_ID; + sc->sample_weight = 0.0f; + } + } + else if (CLOSURE_IS_BSDF_TRANSMISSION(sc->type)) { + if (kernel_data.integrator.filter_closures & FILTER_CLOSURE_TRANSMISSION) { + sc->type = CLOSURE_NONE_ID; + sc->sample_weight = 0.0f; + } + } + } + } + } + /* Defensive sampling. * * We can likely also do defensive sampling at deeper bounces, particularly diff --git a/intern/cycles/kernel/types.h b/intern/cycles/kernel/types.h index 2827139d511..4d4246d2a74 100644 --- a/intern/cycles/kernel/types.h +++ b/intern/cycles/kernel/types.h @@ -430,6 +430,16 @@ typedef struct BsdfEval { float3 glossy; } BsdfEval; +/* Closure Filter */ + +typedef enum FilterClosures { + FILTER_CLOSURE_EMISSION = (1 << 0), + FILTER_CLOSURE_DIFFUSE = (1 << 1), + FILTER_CLOSURE_GLOSSY = (1 << 2), + FILTER_CLOSURE_TRANSMISSION = (1 << 3), + FILTER_CLOSURE_DIRECT_LIGHT = (1 << 4), +} FilterClosures; + /* Shader Flag */ typedef enum ShaderFlag { @@ -1186,7 +1196,11 @@ typedef struct KernelIntegrator { int has_shadow_catcher; float scrambling_distance; + /* Closure filter. */ + int filter_closures; + /* padding */ + int pad1, pad2, pad3; } KernelIntegrator; static_assert_align(KernelIntegrator, 16); |