[Bf-blender-cvs] [4d3a003] cycles_disney_brdf: Enhanced performance for Disney materials without subsurface scattering

Pascal Schoen noreply at git.blender.org
Tue Sep 27 11:22:34 CEST 2016


Commit: 4d3a0032ecea99031979f342bfd5f66ea5a8625a
Author: Pascal Schoen
Date:   Mon Sep 26 12:35:36 2016 +0200
Branches: cycles_disney_brdf
https://developer.blender.org/rB4d3a0032ecea99031979f342bfd5f66ea5a8625a

Enhanced performance for Disney materials without subsurface scattering

===================================================================

M	intern/cycles/kernel/svm/svm_closure.h

===================================================================

diff --git a/intern/cycles/kernel/svm/svm_closure.h b/intern/cycles/kernel/svm/svm_closure.h
index d3ed0bd..8aca266 100644
--- a/intern/cycles/kernel/svm/svm_closure.h
+++ b/intern/cycles/kernel/svm/svm_closure.h
@@ -149,7 +149,25 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
 			if (path_flag & PATH_RAY_DIFFUSE_ANCESTOR)
 				subsurface = 0.0f;
 
-			if (subsurf_sample_weight > CLOSURE_WEIGHT_CUTOFF) {
+			if (subsurface < CLOSURE_WEIGHT_CUTOFF) {
+				/* diffuse */
+				if (diffuse_weight > CLOSURE_WEIGHT_CUTOFF && fabsf(average(baseColor)) > CLOSURE_WEIGHT_CUTOFF) {
+					float3 diff_weight = weight * diffuse_weight;
+					float diff_sample_weight = fabsf(average(diff_weight));
+
+					DisneyDiffuseBsdf *bsdf = (DisneyDiffuseBsdf*)bsdf_alloc(sd, sizeof(DisneyDiffuseBsdf), diff_weight);
+
+					if (bsdf) {
+						bsdf->N = N;
+						bsdf->baseColor = baseColor;
+						bsdf->roughness = roughness;
+
+						/* setup bsdf */
+						ccl_fetch(sd, flag) |= bsdf_disney_diffuse_setup(bsdf);
+					}
+				}
+			}
+			else if (subsurf_sample_weight > CLOSURE_WEIGHT_CUTOFF) {
 				/* radius * scale */
 				float3 radius = make_float3(1.0f, 1.0f, 1.0f) * subsurface;
 				/* sharpness */
@@ -239,7 +257,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
 #ifdef __CAUSTICS_TRICKS__
 			if (kernel_data.integrator.caustics_reflective || (path_flag & PATH_RAY_DIFFUSE) == 0) {
 #endif
-				if (specular > CLOSURE_WEIGHT_CUTOFF || metallic > CLOSURE_WEIGHT_CUTOFF) {
+				if (specular_weight > CLOSURE_WEIGHT_CUTOFF && (specular > CLOSURE_WEIGHT_CUTOFF || metallic > CLOSURE_WEIGHT_CUTOFF)) {
 					float3 spec_weight = weight * specular_weight/* * (specular * (1.0f - metallic) + metallic)*/;
 
 					MicrofacetBsdf *bsdf = (MicrofacetBsdf*)bsdf_alloc(sd, sizeof(MicrofacetBsdf), spec_weight);




More information about the Bf-blender-cvs mailing list