[Bf-blender-cvs] [57f93bf448a] temp-cycles-denoising: Cycles Denoising: Avoid useless calculation in branched path tracing if denoising is disabled
Lukas Stockner
noreply at git.blender.org
Fri Apr 14 00:57:48 CEST 2017
Commit: 57f93bf448abfcee60e587383d397a16887ace3c
Author: Lukas Stockner
Date: Fri Apr 14 00:29:56 2017 +0200
Branches: temp-cycles-denoising
https://developer.blender.org/rB57f93bf448abfcee60e587383d397a16887ace3c
Cycles Denoising: Avoid useless calculation in branched path tracing if denoising is disabled
===================================================================
M intern/cycles/kernel/kernel_path.h
M intern/cycles/kernel/kernel_path_branched.h
M intern/cycles/kernel/kernel_path_surface.h
M intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h
M intern/cycles/kernel/split/kernel_next_iteration_setup.h
===================================================================
diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h
index 8136a6f5998..a5b630f6042 100644
--- a/intern/cycles/kernel/kernel_path.h
+++ b/intern/cycles/kernel/kernel_path.h
@@ -364,6 +364,8 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
throughput /= probability;
}
+ kernel_update_denoising_features(kg, sd, state, L);
+
#ifdef __AO__
/* ambient occlusion */
if(kernel_data.integrator.use_ambient_occlusion || (sd->flag & SD_AO)) {
@@ -371,8 +373,6 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg,
}
#endif /* __AO__ */
- kernel_update_denoising_features(kg, sd, state, L);
-
#ifdef __SUBSURFACE__
/* bssrdf scatter to a different location on the same object, replacing
* the closures with a diffuse BSDF */
@@ -716,6 +716,8 @@ ccl_device_inline float kernel_path_integrate(KernelGlobals *kg,
throughput /= probability;
}
+ kernel_update_denoising_features(kg, &sd, &state, L);
+
#ifdef __AO__
/* ambient occlusion */
if(kernel_data.integrator.use_ambient_occlusion || (sd.flag & SD_AO)) {
@@ -723,8 +725,6 @@ ccl_device_inline float kernel_path_integrate(KernelGlobals *kg,
}
#endif /* __AO__ */
- kernel_update_denoising_features(kg, &sd, &state, L);
-
#ifdef __SUBSURFACE__
/* bssrdf scatter to a different location on the same object, replacing
* the closures with a diffuse BSDF */
diff --git a/intern/cycles/kernel/kernel_path_branched.h b/intern/cycles/kernel/kernel_path_branched.h
index 5f31ad8679d..943a4835068 100644
--- a/intern/cycles/kernel/kernel_path_branched.h
+++ b/intern/cycles/kernel/kernel_path_branched.h
@@ -73,27 +73,30 @@ ccl_device_noinline void kernel_branched_path_surface_indirect_light(KernelGloba
{
float sum_sample_weight = 0.0f;
#ifdef __DENOISING_FEATURES__
- for(int i = 0; i < sd->num_closure; i++) {
- const ShaderClosure *sc = &sd->closure[i];
+ if(state->denoising_feature_weight > 0.0f) {
+ for(int i = 0; i < sd->num_closure; i++) {
+ const ShaderClosure *sc = &sd->closure[i];
- if(!CLOSURE_IS_BSDF(sc->type))
- continue;
- /* transparency is not handled here, but in outer loop */
- if(sc->type == CLOSURE_BSDF_TRANSPARENT_ID)
- continue;
+ /* transparency is not handled here, but in outer loop */
+ if(!CLOSURE_IS_BSDF(sc->type) || CLOSURE_IS_BSDF_TRANSPARENT(sc->type)) {
+ continue;
+ }
- sum_sample_weight += sc->sample_weight;
+ sum_sample_weight += sc->sample_weight;
+ }
+ }
+ else {
+ sum_sample_weight = 1.0f;
}
#endif /* __DENOISING_FEATURES__ */
for(int i = 0; i < sd->num_closure; i++) {
const ShaderClosure *sc = &sd->closure[i];
- if(!CLOSURE_IS_BSDF(sc->type))
- continue;
/* transparency is not handled here, but in outer loop */
- if(sc->type == CLOSURE_BSDF_TRANSPARENT_ID)
+ if(!CLOSURE_IS_BSDF(sc->type) || CLOSURE_IS_BSDF_TRANSPARENT(sc->type)) {
continue;
+ }
int num_samples;
@@ -558,6 +561,8 @@ ccl_device float kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, int
}
}
+ kernel_update_denoising_features(kg, &sd, &state, L);
+
#ifdef __AO__
/* ambient occlusion */
if(kernel_data.integrator.use_ambient_occlusion || (sd.flag & SD_AO)) {
@@ -565,8 +570,6 @@ ccl_device float kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, int
}
#endif /* __AO__ */
- kernel_update_denoising_features(kg, &sd, &state, L);
-
#ifdef __SUBSURFACE__
/* bssrdf scatter to a different location on the same object */
if(sd.flag & SD_BSSRDF) {
diff --git a/intern/cycles/kernel/kernel_path_surface.h b/intern/cycles/kernel/kernel_path_surface.h
index 3bc8db909bc..a24427931fe 100644
--- a/intern/cycles/kernel/kernel_path_surface.h
+++ b/intern/cycles/kernel/kernel_path_surface.h
@@ -177,7 +177,7 @@ ccl_device bool kernel_branched_path_surface_bounce(
path_radiance_bsdf_bounce(L, throughput, &bsdf_eval, bsdf_pdf, state->bounce, label);
#ifdef __DENOISING_FEATURES__
- state->denoising_feature_weight *= (sc->sample_weight / sum_sample_weight) * (1.0f / num_samples);
+ state->denoising_feature_weight *= sc->sample_weight / (sum_sample_weight * num_samples);
#endif
/* modify path state */
diff --git a/intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h b/intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h
index 9fc853a84bf..8879ed8c18c 100644
--- a/intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h
+++ b/intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h
@@ -219,6 +219,8 @@ ccl_device void kernel_holdout_emission_blurring_pathtermination_ao(
kernel_split_state.throughput[ray_index] = throughput/probability;
}
}
+
+ kernel_update_denoising_features(kg, sd, state, L);
}
}
diff --git a/intern/cycles/kernel/split/kernel_next_iteration_setup.h b/intern/cycles/kernel/split/kernel_next_iteration_setup.h
index b685d52ac89..88a0d965ad4 100644
--- a/intern/cycles/kernel/split/kernel_next_iteration_setup.h
+++ b/intern/cycles/kernel/split/kernel_next_iteration_setup.h
@@ -153,8 +153,6 @@ ccl_device void kernel_next_iteration_setup(KernelGlobals *kg,
L = &kernel_split_state.path_radiance[ray_index];
ShaderData *sd = &kernel_split_state.sd[ray_index];
- kernel_update_denoising_features(kg, sd, state, L);
-
/* Compute direct lighting and next bounce. */
if(!kernel_path_surface_bounce(kg, &rng, sd, throughput, state, L, ray)) {
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER);
More information about the Bf-blender-cvs
mailing list