Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2013-04-09 19:24:20 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-04-09 19:24:20 +0400
commite802efb7afa0f3bb0d5d4fad37abce4148bb9ea4 (patch)
tree37013972ad4773ee1be37c9a77481fa67b4f46d8 /intern
parent64d1714586a5ee6b7e0f8b4d8e66dc6abf355316 (diff)
Fix #34740: cycles rendering issue mixing glossy/glass BSDF's with zero or very
low roughness and same index of refraction. Problem was bad float precision due to low roughness, which caused the pdf for the different closures to not match properly.
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/kernel/closure/bsdf_microfacet.h18
-rw-r--r--intern/cycles/kernel/closure/bsdf_refraction.h2
2 files changed, 10 insertions, 10 deletions
diff --git a/intern/cycles/kernel/closure/bsdf_microfacet.h b/intern/cycles/kernel/closure/bsdf_microfacet.h
index 019ec105111..b771e02f131 100644
--- a/intern/cycles/kernel/closure/bsdf_microfacet.h
+++ b/intern/cycles/kernel/closure/bsdf_microfacet.h
@@ -46,7 +46,7 @@ __device int bsdf_microfacet_ggx_setup(ShaderClosure *sc)
{
float ag = sc->data0;
- float m_ag = clamp(ag, 1e-4f, 1.0f);
+ float m_ag = clamp(ag, 1e-3f, 1.0f);
sc->data0 = m_ag;
sc->type = CLOSURE_BSDF_MICROFACET_GGX_ID;
@@ -59,7 +59,7 @@ __device int bsdf_microfacet_ggx_refraction_setup(ShaderClosure *sc)
float ag = sc->data0;
float eta = sc->data1;
- float m_ag = clamp(ag, 1e-4f, 1.0f);
+ float m_ag = clamp(ag, 1e-3f, 1.0f);
float m_eta = eta;
sc->data0 = m_ag;
@@ -256,7 +256,7 @@ __device int bsdf_microfacet_ggx_sample(const ShaderClosure *sc, float3 Ng, floa
__device int bsdf_microfacet_beckmann_setup(ShaderClosure *sc)
{
float ab = sc->data0;
- float m_ab = clamp(ab, 1e-4f, 1.0f);
+ float m_ab = clamp(ab, 1e-3f, 1.0f);
sc->data0 = m_ab;
@@ -268,7 +268,7 @@ __device int bsdf_microfacet_beckmann_refraction_setup(ShaderClosure *sc)
{
float ab = sc->data0;
float eta = sc->data1;
- float m_ab = clamp(ab, 1e-4f, 1.0f);
+ float m_ab = clamp(ab, 1e-3f, 1.0f);
float m_eta = eta;
sc->data0 = m_ab;
@@ -343,7 +343,7 @@ __device float3 bsdf_microfacet_beckmann_eval_transmit(const ShaderClosure *sc,
float cosHI = dot(Ht, omega_in);
// eq. 33: first we calculate D(m) with m=Ht:
float alpha2 = m_ab * m_ab;
- float cosThetaM = dot(N, Ht);
+ float cosThetaM = min(dot(N, Ht), 1.0f);
float cosThetaM2 = cosThetaM * cosThetaM;
float tanThetaM2 = (1 - cosThetaM2) / cosThetaM2;
float cosThetaM4 = cosThetaM2 * cosThetaM2;
@@ -405,8 +405,8 @@ __device int bsdf_microfacet_beckmann_sample(const ShaderClosure *sc, float3 Ng,
// Eval BRDF*cosNI
float cosNI = dot(N, *omega_in);
// eq. 26, 27: now calculate G1(i,m) and G1(o,m)
- float ao = 1 / (m_ab * safe_sqrtf((1 - cosNO * cosNO) / (cosNO * cosNO)));
- float ai = 1 / (m_ab * safe_sqrtf((1 - cosNI * cosNI) / (cosNI * cosNI)));
+ float ao = 1 / (safe_sqrtf(alpha2 * (1 - cosNO * cosNO) / (cosNO * cosNO)));
+ float ai = 1 / (safe_sqrtf(alpha2 * (1 - cosNI * cosNI) / (cosNI * cosNI)));
float G1o = ao < 1.6f ? (3.535f * ao + 2.181f * ao * ao) / (1 + 2.276f * ao + 2.577f * ao * ao) : 1.0f;
float G1i = ai < 1.6f ? (3.535f * ai + 2.181f * ai * ai) / (1 + 2.276f * ai + 2.577f * ai * ai) : 1.0f;
float G = G1o * G1i;
@@ -452,8 +452,8 @@ __device int bsdf_microfacet_beckmann_sample(const ShaderClosure *sc, float3 Ng,
// eval BRDF*cosNI
float cosNI = dot(N, *omega_in);
// eq. 26, 27: now calculate G1(i,m) and G1(o,m)
- float ao = 1 / (m_ab * safe_sqrtf((1 - cosNO * cosNO) / (cosNO * cosNO)));
- float ai = 1 / (m_ab * safe_sqrtf((1 - cosNI * cosNI) / (cosNI * cosNI)));
+ float ao = 1 / (safe_sqrtf(alpha2 * (1 - cosNO * cosNO) / (cosNO * cosNO)));
+ float ai = 1 / (safe_sqrtf(alpha2 * (1 - cosNI * cosNI) / (cosNI * cosNI)));
float G1o = ao < 1.6f ? (3.535f * ao + 2.181f * ao * ao) / (1 + 2.276f * ao + 2.577f * ao * ao) : 1.0f;
float G1i = ai < 1.6f ? (3.535f * ai + 2.181f * ai * ai) / (1 + 2.276f * ai + 2.577f * ai * ai) : 1.0f;
float G = G1o * G1i;
diff --git a/intern/cycles/kernel/closure/bsdf_refraction.h b/intern/cycles/kernel/closure/bsdf_refraction.h
index ef79d6cc259..8565c99d04e 100644
--- a/intern/cycles/kernel/closure/bsdf_refraction.h
+++ b/intern/cycles/kernel/closure/bsdf_refraction.h
@@ -74,7 +74,7 @@ __device int bsdf_refraction_sample(const ShaderClosure *sc, float3 Ng, float3 I
&inside);
if(!inside) {
- *pdf = 1;
+ *pdf = 1.0f;
*eval = make_float3(1.0f, 1.0f, 1.0f);
*omega_in = T;
#ifdef __RAY_DIFFERENTIALS__