From a378f8d2d8f7d30eb699ee2f16e111f60b7900df Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 15 Jul 2014 15:56:40 +0600 Subject: Fix T40964: Massive shading failures with glass node mixing, whiteouts and blackouts --- intern/cycles/kernel/closure/bsdf_microfacet.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'intern') diff --git a/intern/cycles/kernel/closure/bsdf_microfacet.h b/intern/cycles/kernel/closure/bsdf_microfacet.h index df0644becee..870b56803bb 100644 --- a/intern/cycles/kernel/closure/bsdf_microfacet.h +++ b/intern/cycles/kernel/closure/bsdf_microfacet.h @@ -513,6 +513,10 @@ ccl_device float3 bsdf_microfacet_ggx_eval_transmit(const ShaderClosure *sc, con float cosHO = dot(Ht, I); float cosHI = dot(Ht, omega_in); + /* those situations makes chi+ terms in eq. 33, 34 be zero */ + if(dot(Ht, N) <= 0.0f || cosHO * cosNO <= 0.0f || cosHI * cosNI <= 0.0f) + return make_float3(0.0f, 0.0f, 0.0f); + float D, G1o, G1i; /* eq. 33: first we calculate D(m) with m=Ht: */ @@ -862,7 +866,11 @@ ccl_device float3 bsdf_microfacet_beckmann_eval_transmit(const ShaderClosure *sc float cosHO = dot(Ht, I); float cosHI = dot(Ht, omega_in); - /* eq. 33: first we calculate D(m) with m=Ht: */ + /* those situations makes chi+ terms in eq. 25, 27 be zero */ + if(dot(Ht, N) <= 0.0f || cosHO * cosNO <= 0.0f || cosHI * cosNI <= 0.0f) + return make_float3(0.0f, 0.0f, 0.0f); + + /* eq. 25: first we calculate D(m) with m=Ht: */ float alpha2 = alpha_x * alpha_y; float cosThetaM = min(dot(N, Ht), 1.0f); float cosThetaM2 = cosThetaM * cosThetaM; -- cgit v1.2.3