diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-02-10 16:20:36 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-02-10 16:20:36 +0300 |
commit | b03ac8384389a4ad34bd6bcf0cc7be204c7ada9f (patch) | |
tree | 56a2a1fc83fda557418c1bc37174e9044de380f2 /intern | |
parent | 298d8681a0ac28ccc96e593a02ad34a5cef624c6 (diff) |
Cycles: Correction to glossy shaders not handling total internal reflection
The issue was caused by lack of check for whether fresnel term is actually
giving total internal reflection in refraction BSDFs. This lead to usage of
arbitrary vector of (0, 0, 0) as reflection, giving numeric issues in other
areas of the kernel.
This gives some visual changes of sharp reflection but it seems to be rather
proper now. Which also corresponds with rough glossy reflection with sharpness
set to 0.001 (previously it was totally different from sharpness of 0.0, which
is just weird).
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/kernel/closure/bsdf_microfacet.h | 12 | ||||
-rw-r--r-- | intern/cycles/kernel/closure/bsdf_refraction.h | 5 |
2 files changed, 9 insertions, 8 deletions
diff --git a/intern/cycles/kernel/closure/bsdf_microfacet.h b/intern/cycles/kernel/closure/bsdf_microfacet.h index 9561885525f..20dced2fe00 100644 --- a/intern/cycles/kernel/closure/bsdf_microfacet.h +++ b/intern/cycles/kernel/closure/bsdf_microfacet.h @@ -591,16 +591,16 @@ ccl_device int bsdf_microfacet_ggx_sample(KernelGlobals *kg, const ShaderClosure #ifdef __RAY_DIFFERENTIALS__ float3 dRdx, dRdy, dTdx, dTdy; #endif - float m_eta = sc->data2; + float m_eta = sc->data2, fresnel; bool inside; - fresnel_dielectric(m_eta, m, I, &R, &T, + fresnel = fresnel_dielectric(m_eta, m, I, &R, &T, #ifdef __RAY_DIFFERENTIALS__ dIdx, dIdy, &dRdx, &dRdy, &dTdx, &dTdy, #endif &inside); - if(!inside) { + if(!inside && fresnel != 1.0f) { *omega_in = T; #ifdef __RAY_DIFFERENTIALS__ @@ -945,16 +945,16 @@ ccl_device int bsdf_microfacet_beckmann_sample(KernelGlobals *kg, const ShaderCl #ifdef __RAY_DIFFERENTIALS__ float3 dRdx, dRdy, dTdx, dTdy; #endif - float m_eta = sc->data2; + float m_eta = sc->data2, fresnel; bool inside; - fresnel_dielectric(m_eta, m, I, &R, &T, + fresnel = fresnel_dielectric(m_eta, m, I, &R, &T, #ifdef __RAY_DIFFERENTIALS__ dIdx, dIdy, &dRdx, &dRdy, &dTdx, &dTdy, #endif &inside); - if(!inside) { + if(!inside && fresnel != 1.0f) { *omega_in = T; #ifdef __RAY_DIFFERENTIALS__ diff --git a/intern/cycles/kernel/closure/bsdf_refraction.h b/intern/cycles/kernel/closure/bsdf_refraction.h index c96ac62fafa..02a06941afa 100644 --- a/intern/cycles/kernel/closure/bsdf_refraction.h +++ b/intern/cycles/kernel/closure/bsdf_refraction.h @@ -67,13 +67,14 @@ ccl_device int bsdf_refraction_sample(const ShaderClosure *sc, float3 Ng, float3 float3 dRdx, dRdy, dTdx, dTdy; #endif bool inside; - fresnel_dielectric(m_eta, N, I, &R, &T, + float fresnel; + fresnel = fresnel_dielectric(m_eta, N, I, &R, &T, #ifdef __RAY_DIFFERENTIALS__ dIdx, dIdy, &dRdx, &dRdy, &dTdx, &dTdy, #endif &inside); - if(!inside) { + if(!inside && fresnel != 1.0f) { /* Some high number for MIS. */ *pdf = 1e6f; *eval = make_float3(1e6f, 1e6f, 1e6f); |