[Bf-blender-cvs] [18bf900b31] master: Fix T50990: Random black pixels in Cycles when rendering material with Multiscatter GGX

Sergey Sharybin noreply at git.blender.org
Mon Mar 20 12:08:05 CET 2017


Commit: 18bf900b3137b46be9dd8c8645c710b2878ffcc6
Author: Sergey Sharybin
Date:   Mon Mar 20 12:07:41 2017 +0100
Branches: master
https://developer.blender.org/rB18bf900b3137b46be9dd8c8645c710b2878ffcc6

Fix T50990: Random black pixels in Cycles when rendering material with Multiscatter GGX

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

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

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

diff --git a/intern/cycles/kernel/closure/bsdf_microfacet_multi.h b/intern/cycles/kernel/closure/bsdf_microfacet_multi.h
index cea59adfeb..aa4b91eac4 100644
--- a/intern/cycles/kernel/closure/bsdf_microfacet_multi.h
+++ b/intern/cycles/kernel/closure/bsdf_microfacet_multi.h
@@ -43,7 +43,7 @@ ccl_device_forceinline float D_ggx_aniso(const float3 wm, const float2 alpha)
 ccl_device_forceinline float2 mf_sampleP22_11(const float cosI, const float2 randU)
 {
 	if(cosI > 0.9999f || cosI < 1e-6f) {
-		const float r = sqrtf(randU.x / (1.0f - randU.x));
+		const float r = sqrtf(randU.x / max(1.0f - randU.x, 1e-7f));
 		const float phi = M_2PI_F * randU.y;
 		return make_float2(r*cosf(phi), r*sinf(phi));
 	}
@@ -83,7 +83,7 @@ ccl_device_forceinline float3 mf_sample_vndf(const float3 wi, const float2 alpha
 	const float3 wi_11 = normalize(make_float3(alpha.x*wi.x, alpha.y*wi.y, wi.z));
 	const float2 slope_11 = mf_sampleP22_11(wi_11.z, randU);
 
-	const float2 cossin_phi = normalize(make_float2(wi_11.x, wi_11.y));
+	const float2 cossin_phi = safe_normalize(make_float2(wi_11.x, wi_11.y));
 	const float slope_x = alpha.x*(cossin_phi.x * slope_11.x - cossin_phi.y * slope_11.y);
 	const float slope_y = alpha.y*(cossin_phi.y * slope_11.x + cossin_phi.x * slope_11.y);




More information about the Bf-blender-cvs mailing list