[Bf-blender-cvs] [d85a0a722e5] master: Fix part of T53038: principled BSDF clearcoat weight has no effect with 0 roughness.

Brecht Van Lommel noreply at git.blender.org
Wed Oct 18 23:36:20 CEST 2017


Commit: d85a0a722e5f00d2ce6ae7c35953859646c36d09
Author: Brecht Van Lommel
Date:   Wed Oct 18 23:11:16 2017 +0200
Branches: master
https://developer.blender.org/rBd85a0a722e5f00d2ce6ae7c35953859646c36d09

Fix part of T53038: principled BSDF clearcoat weight has no effect with 0 roughness.

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

M	intern/cycles/kernel/closure/bsdf_microfacet.h

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

diff --git a/intern/cycles/kernel/closure/bsdf_microfacet.h b/intern/cycles/kernel/closure/bsdf_microfacet.h
index a780bd0cf28..18b645e0ecb 100644
--- a/intern/cycles/kernel/closure/bsdf_microfacet.h
+++ b/intern/cycles/kernel/closure/bsdf_microfacet.h
@@ -409,8 +409,6 @@ ccl_device float3 bsdf_microfacet_ggx_eval_reflect(const ShaderClosure *sc, cons
 		float alpha2 = alpha_x * alpha_y;
 		float D, G1o, G1i;
 
-		bool is_principled_clearcoat = (bsdf->type == CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID);
-
 		if(alpha_x == alpha_y) {
 			/* isotropic
 			 * eq. 20: (F*G*D)/(4*in*on)
@@ -420,7 +418,7 @@ ccl_device float3 bsdf_microfacet_ggx_eval_reflect(const ShaderClosure *sc, cons
 			float cosThetaM4 = cosThetaM2 * cosThetaM2;
 			float tanThetaM2 = (1 - cosThetaM2) / cosThetaM2;
 
-			if(is_principled_clearcoat) {
+			if(bsdf->type == CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID) {
 				/* use GTR1 for clearcoat */
 				D = D_GTR1(cosThetaM, bsdf->alpha_x);
 
@@ -479,7 +477,7 @@ ccl_device float3 bsdf_microfacet_ggx_eval_reflect(const ShaderClosure *sc, cons
 		float common = D * 0.25f / cosNO;
 
 		float3 F = reflection_color(bsdf, omega_in, m);
-		if(is_principled_clearcoat) {
+		if(bsdf->type == CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID) {
 			F *= 0.25f * bsdf->extra->clearcoat;
 		}
 
@@ -616,8 +614,6 @@ ccl_device int bsdf_microfacet_ggx_sample(KernelGlobals *kg, const ShaderClosure
 						float alpha2 = alpha_x * alpha_y;
 						float D, G1i;
 
-						bool is_principled_clearcoat = (bsdf->type == CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID);
-
 						if(alpha_x == alpha_y) {
 							/* isotropic */
 							float cosThetaM2 = cosThetaM * cosThetaM;
@@ -627,7 +623,7 @@ ccl_device int bsdf_microfacet_ggx_sample(KernelGlobals *kg, const ShaderClosure
 							/* eval BRDF*cosNI */
 							float cosNI = dot(N, *omega_in);
 
-							if(is_principled_clearcoat) {
+							if(bsdf->type == CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID) {
 								/* use GTR1 for clearcoat */
 								D = D_GTR1(cosThetaM, bsdf->alpha_x);
 
@@ -643,7 +639,7 @@ ccl_device int bsdf_microfacet_ggx_sample(KernelGlobals *kg, const ShaderClosure
 							}
 
 							/* eq. 34: now calculate G1(i,m) */
-							G1i = 2 / (1 + safe_sqrtf(1 + alpha2 * (1 - cosNI * cosNI) / (cosNI * cosNI))); 
+							G1i = 2 / (1 + safe_sqrtf(1 + alpha2 * (1 - cosNI * cosNI) / (cosNI * cosNI)));
 						}
 						else {
 							/* anisotropic distribution */
@@ -676,13 +672,14 @@ ccl_device int bsdf_microfacet_ggx_sample(KernelGlobals *kg, const ShaderClosure
 						*pdf = common;
 
 						float3 F = reflection_color(bsdf, *omega_in, m);
-						if(is_principled_clearcoat) {
-							F *= 0.25f * bsdf->extra->clearcoat;
-						}
 
 						*eval = G1i * common * F;
 					}
 
+					if(bsdf->type == CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID) {
+						*eval *= 0.25f * bsdf->extra->clearcoat;
+					}
+
 #ifdef __RAY_DIFFERENTIALS__
 					*domega_in_dx = (2 * dot(m, dIdx)) * m - dIdx;
 					*domega_in_dy = (2 * dot(m, dIdy)) * m - dIdy;



More information about the Bf-blender-cvs mailing list