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
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2013-05-03 17:17:28 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-05-03 17:17:28 +0400
commit356ca7ec8a132732dc656448eabc0d7cc2387cfa (patch)
treecdc1c7369c894625fa0cdff2c3a426234d2ee5ef
parent95271e248ac917f06231c685d77eab34d2cf5736 (diff)
Fix for recent glossy BSDF fix, color ramp test file was rendering different.
-rw-r--r--intern/cycles/kernel/closure/bsdf_microfacet.h41
1 files changed, 27 insertions, 14 deletions
diff --git a/intern/cycles/kernel/closure/bsdf_microfacet.h b/intern/cycles/kernel/closure/bsdf_microfacet.h
index c586c1e3311..d36c337854b 100644
--- a/intern/cycles/kernel/closure/bsdf_microfacet.h
+++ b/intern/cycles/kernel/closure/bsdf_microfacet.h
@@ -78,7 +78,7 @@ __device void bsdf_microfacet_ggx_blur(ShaderClosure *sc, float roughness)
__device float3 bsdf_microfacet_ggx_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
- float m_ag = sc->data0;
+ float m_ag = max(sc->data0, 1e-4f);
int m_refractive = sc->type == CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID;
float3 N = sc->N;
@@ -115,7 +115,7 @@ __device float3 bsdf_microfacet_ggx_eval_reflect(const ShaderClosure *sc, const
__device float3 bsdf_microfacet_ggx_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
- float m_ag = sc->data0;
+ float m_ag = max(sc->data0, 1e-4f);
float m_eta = sc->data1;
int m_refractive = sc->type == CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID;
float3 N = sc->N;
@@ -179,8 +179,9 @@ __device int bsdf_microfacet_ggx_sample(const ShaderClosure *sc, float3 Ng, floa
*omega_in = 2 * cosMO * m - I;
if(dot(Ng, *omega_in) > 0) {
if (m_ag <= 1e-4f) {
- *pdf = 1;
- *eval = make_float3(1, 1, 1);
+ // some high number for MIS
+ *pdf = 1e6f;
+ *eval = make_float3(1e6f, 1e6f, 1e6f);
}
else {
// microfacet normal is visible to this ray
@@ -235,8 +236,9 @@ __device int bsdf_microfacet_ggx_sample(const ShaderClosure *sc, float3 Ng, floa
#endif
if (m_ag <= 1e-4f) {
- *pdf = 1;
- *eval = make_float3(1, 1, 1);
+ // some high number for MIS
+ *pdf = 1e6f;
+ *eval = make_float3(1e6f, 1e6f, 1e6f);
}
else {
// eq. 33
@@ -303,7 +305,7 @@ __device void bsdf_microfacet_beckmann_blur(ShaderClosure *sc, float roughness)
__device float3 bsdf_microfacet_beckmann_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
- float m_ab = sc->data0;
+ float m_ab = max(sc->data0, 1e-4f);
int m_refractive = sc->type == CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID;
float3 N = sc->N;
@@ -342,7 +344,7 @@ __device float3 bsdf_microfacet_beckmann_eval_reflect(const ShaderClosure *sc, c
__device float3 bsdf_microfacet_beckmann_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
- float m_ab = sc->data0;
+ float m_ab = max(sc->data0, 1e-4f);
float m_eta = sc->data1;
int m_refractive = sc->type == CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID;
float3 N = sc->N;
@@ -394,8 +396,17 @@ __device int bsdf_microfacet_beckmann_sample(const ShaderClosure *sc, float3 Ng,
// we take advantage of cos(atan(x)) == 1/sqrt(1+x^2)
//tttt and sin(atan(x)) == x/sqrt(1+x^2)
float alpha2 = m_ab * m_ab;
- float tanThetaM = safe_sqrtf(-alpha2 * logf(1 - randu));
- float cosThetaM = 1 / safe_sqrtf(1 + tanThetaM * tanThetaM);
+ float tanThetaM, cosThetaM;
+
+ if(alpha2 == 0.0f) {
+ tanThetaM = 0.0f;
+ cosThetaM = 1.0f;
+ }
+ else {
+ tanThetaM = safe_sqrtf(-alpha2 * logf(1 - randu));
+ cosThetaM = 1 / safe_sqrtf(1 + tanThetaM * tanThetaM);
+ }
+
float sinThetaM = cosThetaM * tanThetaM;
float phiM = 2 * M_PI_F * randv;
float3 m = (cosf(phiM) * sinThetaM) * X +
@@ -409,8 +420,9 @@ __device int bsdf_microfacet_beckmann_sample(const ShaderClosure *sc, float3 Ng,
*omega_in = 2 * cosMO * m - I;
if(dot(Ng, *omega_in) > 0) {
if (m_ab <= 1e-4f) {
- *pdf = 1;
- *eval = make_float3(1, 1, 1);
+ // some high number for MIS
+ *pdf = 1e6f;
+ *eval = make_float3(1e6f, 1e6f, 1e6f);
}
else {
// microfacet normal is visible to this ray
@@ -466,8 +478,9 @@ __device int bsdf_microfacet_beckmann_sample(const ShaderClosure *sc, float3 Ng,
*domega_in_dy = dTdy;
#endif
if (m_ab <= 1e-4f) {
- *pdf = 1;
- *eval = make_float3(1, 1, 1);
+ // some high number for MIS
+ *pdf = 1e6f;
+ *eval = make_float3(1e6f, 1e6f, 1e6f);
}
else {
// eq. 33