solstice-solver

Solver library of the solstice app
git clone git://git.meso-star.com/solstice-solver.git
Log | Files | Refs | README | LICENSE

commit 1096949a4e631dd621b00513397107e3f3d74558
parent df14b2c60b327164f71f0ce73de87849977923ef
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Tue, 18 Apr 2017 13:38:42 +0200

Fix perturbated normals in the solver

Sampled direction around the shading normal might point on the wrong
surface side wrt the sampled BSDF component.

Diffstat:
Msrc/ssol_solver.c | 9+++++++++
1 file changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/ssol_solver.c b/src/ssol_solver.c @@ -388,8 +388,17 @@ point_shade if(d3_dot(wi, frag.Ns) <= 0) { r = 0; } else { + double cos_dir_Ng; r = ssf_bsdf_sample(bsdf, rng, wi, frag.Ns, dir, &type, &pdf); ASSERT(0 <= r && r <= 1); + + /* Due to the shading normal, the sampled direction may point in the wrong + * direction wrt the sampled BSDF component. */ + cos_dir_Ng = d3_dot(frag.Ng, dir); + if((cos_dir_Ng > 0 && (type & SSF_TRANSMISSION)) + || (cos_dir_Ng < 0 && (type & SSF_REFLECTION))) { + r = 0; + } } pt->reflectivity_loss += (1 - r) * pt->weight; pt->weight *= r;