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 00:54:58 +0300
committerLukas Stockner <lukas.stockner@freenet.de>2020-01-21 01:06:08 +0300
commit902209eda52756f510c7ac21c9075e5ea465ad9e (patch)
treec0e13b94a852beafb58ad67930f509788adef0ed /intern/cycles/kernel/closure
parentaee2b754dc8f5c4ddaf840cd83f979dd22fe4dc3 (diff)
Partial Fix T73043: Denoising Albedo not working well for Sheen
Similar to the Microfacet Closures, the Principled BSDF Sheen closure is added at a high weight but typically results in fairly low values. Therefore, the default weight is a bad indicator of importance. The fix here is the same as it was back then for Microfacets: Compute an average weight using the normal as the half-vector and use it to scale down the sample weight and the albedo channel. In addition to drastically improving denoising of materials with sheen when using the new Denoising node, this also can reduce noise on such materials considerably.
Diffstat (limited to 'intern/cycles/kernel/closure')
-rw-r--r--intern/cycles/kernel/closure/bsdf_principled_sheen.h25
1 files changed, 20 insertions, 5 deletions
diff --git a/intern/cycles/kernel/closure/bsdf_principled_sheen.h b/intern/cycles/kernel/closure/bsdf_principled_sheen.h
index 1326d23668a..3707de29d73 100644
--- a/intern/cycles/kernel/closure/bsdf_principled_sheen.h
+++ b/intern/cycles/kernel/closure/bsdf_principled_sheen.h
@@ -26,13 +26,26 @@ CCL_NAMESPACE_BEGIN
typedef ccl_addr_space struct PrincipledSheenBsdf {
SHADER_CLOSURE_BASE;
+ float avg_value;
} PrincipledSheenBsdf;
static_assert(sizeof(ShaderClosure) >= sizeof(PrincipledSheenBsdf),
"PrincipledSheenBsdf is too large!");
-ccl_device float3 calculate_principled_sheen_brdf(
- const PrincipledSheenBsdf *bsdf, float3 N, float3 V, float3 L, float3 H, float *pdf)
+ccl_device_inline float calculate_avg_principled_sheen_brdf(float3 N, float3 I)
+{
+ /* To compute the average, we set the half-vector to the normal, resulting in
+ * NdotI = NdotL = NdotV = LdotH */
+ float NdotI = dot(N, I);
+ if (NdotI < 0.0f) {
+ return 0.0f;
+ }
+
+ return schlick_fresnel(NdotI) * NdotI;
+}
+
+ccl_device float3
+calculate_principled_sheen_brdf(float3 N, float3 V, float3 L, float3 H, float *pdf)
{
float NdotL = dot(N, L);
float NdotV = dot(N, V);
@@ -49,9 +62,11 @@ ccl_device float3 calculate_principled_sheen_brdf(
return make_float3(value, value, value);
}
-ccl_device int bsdf_principled_sheen_setup(PrincipledSheenBsdf *bsdf)
+ccl_device int bsdf_principled_sheen_setup(const ShaderData *sd, PrincipledSheenBsdf *bsdf)
{
bsdf->type = CLOSURE_BSDF_PRINCIPLED_SHEEN_ID;
+ bsdf->avg_value = calculate_avg_principled_sheen_brdf(bsdf->N, sd->I);
+ bsdf->sample_weight *= bsdf->avg_value;
return SD_BSDF | SD_BSDF_HAS_EVAL;
}
@@ -69,7 +84,7 @@ ccl_device float3 bsdf_principled_sheen_eval_reflect(const ShaderClosure *sc,
if (dot(N, omega_in) > 0.0f) {
*pdf = fmaxf(dot(N, omega_in), 0.0f) * M_1_PI_F;
- return calculate_principled_sheen_brdf(bsdf, N, V, L, H, pdf);
+ return calculate_principled_sheen_brdf(N, V, L, H, pdf);
}
else {
*pdf = 0.0f;
@@ -107,7 +122,7 @@ ccl_device int bsdf_principled_sheen_sample(const ShaderClosure *sc,
if (dot(Ng, *omega_in) > 0) {
float3 H = normalize(I + *omega_in);
- *eval = calculate_principled_sheen_brdf(bsdf, N, I, *omega_in, H, pdf);
+ *eval = calculate_principled_sheen_brdf(N, I, *omega_in, H, pdf);
#ifdef __RAY_DIFFERENTIALS__
// TODO: find a better approximation for the diffuse bounce