Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Stockner <lukas.stockner@freenet.de>2020-01-21 06:45:51 +0300
committerLukas Stockner <lukas.stockner@freenet.de>2020-02-06 05:37:48 +0300
commitdc1db0791ec3b2d52e6734054a001814cd6998ee (patch)
treeb40ba289e33b2a7f11d1d6bada9623b36bdf0886 /intern/cycles/kernel/kernel_passes.h
parent8c353931afe1ac8969bcf7cdadc056f322cb2af8 (diff)
Cycles: Track specular throughput to account for reflection color in denoising albedo pass
To determine the albedo pass, Cycles currently follows the path until a predominantly diffuse-ish material is hit and then takes the albedo there. This works fine for normal mirrors, but as it completely ignores the color of the bounces before that diffuse-ish material, it also means that any textures that are applied to the specular-ish BSDFs won't affect the albedo pass at all. Therefore, this patch changes that behaviour so that Cycles also keeps track of the throughput of all specular-ish closures along the path so far and includes that in the albedo pass. This fixes part of the issue described in T73043. However, since it has an effect on the albedo pass in most scenes, it could cause cause regressions, which is why I'm uploading it as a patch instead of just committing as a fix. Differential Revision: https://developer.blender.org/D6640
Diffstat (limited to 'intern/cycles/kernel/kernel_passes.h')
-rw-r--r--intern/cycles/kernel/kernel_passes.h43
1 files changed, 26 insertions, 17 deletions
diff --git a/intern/cycles/kernel/kernel_passes.h b/intern/cycles/kernel/kernel_passes.h
index 7345e9ee5bb..e50fa07a885 100644
--- a/intern/cycles/kernel/kernel_passes.h
+++ b/intern/cycles/kernel/kernel_passes.h
@@ -58,7 +58,8 @@ ccl_device_inline void kernel_update_denoising_features(KernelGlobals *kg,
}
float3 normal = make_float3(0.0f, 0.0f, 0.0f);
- float3 albedo = make_float3(0.0f, 0.0f, 0.0f);
+ float3 diffuse_albedo = make_float3(0.0f, 0.0f, 0.0f);
+ float3 specular_albedo = make_float3(0.0f, 0.0f, 0.0f);
float sum_weight = 0.0f, sum_nonspecular_weight = 0.0f;
for (int i = 0; i < sd->num_closure; i++) {
@@ -70,24 +71,28 @@ ccl_device_inline void kernel_update_denoising_features(KernelGlobals *kg,
/* All closures contribute to the normal feature, but only diffuse-like ones to the albedo. */
normal += sc->N * sc->sample_weight;
sum_weight += sc->sample_weight;
- if (bsdf_get_specular_roughness_squared(sc) > sqr(0.075f)) {
- float3 closure_albedo = sc->weight;
- /* Closures that include a Fresnel term typically have weights close to 1 even though their
- * actual contribution is significantly lower.
- * To account for this, we scale their weight by the average fresnel factor (the same is also
- * done for the sample weight in the BSDF setup, so we don't need to scale that here). */
- if (CLOSURE_IS_BSDF_MICROFACET_FRESNEL(sc->type)) {
- MicrofacetBsdf *bsdf = (MicrofacetBsdf *)sc;
- closure_albedo *= bsdf->extra->fresnel_color;
- }
- else if (sc->type == CLOSURE_BSDF_PRINCIPLED_SHEEN_ID) {
- PrincipledSheenBsdf *bsdf = (PrincipledSheenBsdf *)sc;
- closure_albedo *= bsdf->avg_value;
- }
- albedo += closure_albedo;
+ float3 closure_albedo = sc->weight;
+ /* Closures that include a Fresnel term typically have weights close to 1 even though their
+ * actual contribution is significantly lower.
+ * To account for this, we scale their weight by the average fresnel factor (the same is also
+ * done for the sample weight in the BSDF setup, so we don't need to scale that here). */
+ if (CLOSURE_IS_BSDF_MICROFACET_FRESNEL(sc->type)) {
+ MicrofacetBsdf *bsdf = (MicrofacetBsdf *)sc;
+ closure_albedo *= bsdf->extra->fresnel_color;
+ }
+ else if (sc->type == CLOSURE_BSDF_PRINCIPLED_SHEEN_ID) {
+ PrincipledSheenBsdf *bsdf = (PrincipledSheenBsdf *)sc;
+ closure_albedo *= bsdf->avg_value;
+ }
+
+ if (bsdf_get_specular_roughness_squared(sc) > sqr(0.075f)) {
+ diffuse_albedo += closure_albedo;
sum_nonspecular_weight += sc->sample_weight;
}
+ else {
+ specular_albedo += closure_albedo;
+ }
}
/* Wait for next bounce if 75% or more sample weight belongs to specular-like closures. */
@@ -101,10 +106,14 @@ ccl_device_inline void kernel_update_denoising_features(KernelGlobals *kg,
normal = transform_direction(&worldtocamera, normal);
L->denoising_normal += ensure_finite3(state->denoising_feature_weight * normal);
- L->denoising_albedo += ensure_finite3(state->denoising_feature_weight * albedo);
+ L->denoising_albedo += ensure_finite3(state->denoising_feature_weight *
+ state->denoising_feature_throughput * diffuse_albedo);
state->denoising_feature_weight = 0.0f;
}
+ else {
+ state->denoising_feature_throughput *= specular_albedo;
+ }
}
#endif /* __DENOISING_FEATURES__ */