diff options
author | Lukas Stockner <lukas.stockner@freenet.de> | 2020-01-21 00:54:58 +0300 |
---|---|---|
committer | Lukas Stockner <lukas.stockner@freenet.de> | 2020-01-21 01:06:08 +0300 |
commit | 902209eda52756f510c7ac21c9075e5ea465ad9e (patch) | |
tree | c0e13b94a852beafb58ad67930f509788adef0ed /intern/cycles/kernel/osl/osl_closures.cpp | |
parent | aee2b754dc8f5c4ddaf840cd83f979dd22fe4dc3 (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/osl/osl_closures.cpp')
-rw-r--r-- | intern/cycles/kernel/osl/osl_closures.cpp | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/intern/cycles/kernel/osl/osl_closures.cpp b/intern/cycles/kernel/osl/osl_closures.cpp index 27205df3732..463a65f21a0 100644 --- a/intern/cycles/kernel/osl/osl_closures.cpp +++ b/intern/cycles/kernel/osl/osl_closures.cpp @@ -197,15 +197,32 @@ CLOSURE_FLOAT3_PARAM(DiffuseClosure, params.N), CLOSURE_FLOAT_PARAM(PrincipledDiffuseClosure, params.roughness), BSDF_CLOSURE_CLASS_END(PrincipledDiffuse, principled_diffuse) - BSDF_CLOSURE_CLASS_BEGIN(PrincipledSheen, - principled_sheen, - PrincipledSheenBsdf, - LABEL_DIFFUSE) - CLOSURE_FLOAT3_PARAM(PrincipledSheenClosure, params.N), - BSDF_CLOSURE_CLASS_END(PrincipledSheen, principled_sheen) + class PrincipledSheenClosure : public CBSDFClosure { + public: + PrincipledSheenBsdf params; + + void setup(ShaderData *sd, int path_flag, float3 weight) + { + if (!skip(sd, path_flag, LABEL_DIFFUSE)) { + PrincipledSheenBsdf *bsdf = (PrincipledSheenBsdf *)bsdf_alloc_osl( + sd, sizeof(PrincipledSheenBsdf), weight, ¶ms); + sd->flag |= (bsdf) ? bsdf_principled_sheen_setup(sd, bsdf) : 0; + } + } +}; - /* PRINCIPLED HAIR BSDF */ - class PrincipledHairClosure : public CBSDFClosure { +static ClosureParam *bsdf_principled_sheen_params() +{ + static ClosureParam params[] = {CLOSURE_FLOAT3_PARAM(PrincipledSheenClosure, params.N), + CLOSURE_STRING_KEYPARAM(PrincipledSheenClosure, label, "label"), + CLOSURE_FINISH_PARAM(PrincipledSheenClosure)}; + return params; +} + +CCLOSURE_PREPARE_STATIC(closure_bsdf_principled_sheen_prepare, PrincipledSheenClosure) + +/* PRINCIPLED HAIR BSDF */ +class PrincipledHairClosure : public CBSDFClosure { public: PrincipledHairBSDF params; @@ -425,8 +442,11 @@ void OSLShader::register_closures(OSLShadingSystem *ss_) id++, bsdf_principled_diffuse_params(), bsdf_principled_diffuse_prepare); - register_closure( - ss, "principled_sheen", id++, bsdf_principled_sheen_params(), bsdf_principled_sheen_prepare); + register_closure(ss, + "principled_sheen", + id++, + bsdf_principled_sheen_params(), + closure_bsdf_principled_sheen_prepare); register_closure(ss, "principled_clearcoat", id++, |