Cycles: Enable SSS from Principled BSDF only when actually in use
authorMai Lavelle <mai.lavelle@gmail.com>
Wed, 12 Jul 2017 08:36:46 +0000 (04:36 -0400)
committerMai Lavelle <mai.lavelle@gmail.com>
Wed, 12 Jul 2017 08:40:24 +0000 (04:40 -0400)
This gives speed up for the split kernel in scenes using the principled BSDF
but without subsurface scattering.

intern/cycles/render/nodes.cpp
intern/cycles/render/nodes.h

index 166156f7ac3525b1ba590bbe2631967e47ac765c..86e25df1da39ffaef2aa19b651f0e003b3da1d95 100644 (file)
@@ -2337,6 +2337,12 @@ PrincipledBsdfNode::PrincipledBsdfNode()
        distribution_orig = NBUILTIN_CLOSURES;
 }
 
+bool PrincipledBsdfNode::has_surface_bssrdf()
+{
+       ShaderInput *subsurface_in = input("Subsurface");
+       return (subsurface_in->link != NULL || subsurface > CLOSURE_WEIGHT_CUTOFF);
+}
+
 void PrincipledBsdfNode::attributes(Shader *shader, AttributeRequestSet *attributes)
 {
        if(shader->has_surface) {
index c6ab47fcc84d46c049e61ebbd903d1625d06e92f..c0271a3c8eb1cfa6382c57da669c49255e3ebe26 100644 (file)
@@ -374,7 +374,7 @@ public:
        SHADER_NODE_CLASS(PrincipledBsdfNode)
 
        bool has_spatial_varying() { return true; }
-       bool has_surface_bssrdf() { return true; }
+       bool has_surface_bssrdf();
        bool has_bssrdf_bump();
        void compile(SVMCompiler& compiler, ShaderInput *metallic, ShaderInput *subsurface, ShaderInput *subsurface_radius,
                ShaderInput *specular, ShaderInput *roughness, ShaderInput *specular_tint, ShaderInput *anisotropic,