solstice-solver

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

commit 058ea19fab3b15021debd1f3e6d74de7e9b1d87a
parent fe3e818c510d064e9ad05b7fe874a2d96b900384
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon, 27 Mar 2017 14:37:09 +0200

Fix the "point_shade" ssol_solver function

This function aborts if the sun direction and the surface normal were
orthogonal.

Diffstat:
Msrc/ssol_solver.c | 18+++++++++++-------
Msrc/test_ssol_solver9.c | 26+++++++++++++-------------
2 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/src/ssol_solver.c b/src/ssol_solver.c @@ -233,7 +233,11 @@ point_init ranst_sun_dir_get(ran_sun_dir, rng, pt->dir); /* Initialise the Monte Carlo weight */ - if(pt->sshape->shape->type == SHAPE_PUNCHED) { + if(pt->sshape->shape->type != SHAPE_PUNCHED) { + double surface_sun_cos = fabs(d3_dot(pt->N, pt->dir)); + pt->weight = scn->sun->dni * sampled_area_proxy * surface_sun_cos; + pt->cos_loss = scn->sun->dni * sampled_area_proxy * (1 - surface_sun_cos); + } else { double proxy_sun_cos = fabs(d3_dot(pt->N, pt->dir)); double cos_ratio, surface_proxy_cos, surface_sun_cos, tmp_n[3]; /* For punched surface, retrieve the sampled position and normal onto the @@ -246,10 +250,6 @@ point_init d3_set(pt->N, tmp_n); pt->weight = scn->sun->dni * sampled_area_proxy * cos_ratio; pt->cos_loss = scn->sun->dni * sampled_area_proxy * (1 - proxy_sun_cos); - } else { - double surface_sun_cos = fabs(d3_dot(pt->N, pt->dir)); - pt->weight = scn->sun->dni * sampled_area_proxy * surface_sun_cos; - pt->cos_loss = scn->sun->dni * sampled_area_proxy * (1 - surface_sun_cos); } pt->absorptivity_loss = pt->reflectivity_loss = 0; @@ -376,8 +376,12 @@ point_shade * directions point outward the surface => negate incoming dir */ d3_minus(wi, pt->dir); - r = ssf_bsdf_sample(bsdf, rng, wi, frag.Ns, dir, &pdf); - ASSERT(0 <= r && r <= 1); + if(d3_dot(wi, frag.Ns) <= 0) { + r = 0; + } else { + r = ssf_bsdf_sample(bsdf, rng, wi, frag.Ns, dir, &pdf); + ASSERT(0 <= r && r <= 1); + } pt->reflectivity_loss += (1 - r) * pt->weight; pt->weight *= r; diff --git a/src/test_ssol_solver9.c b/src/test_ssol_solver9.c @@ -1,17 +1,17 @@ /* Copyright (C) CNRS 2016-2017 -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see <http://www.gnu.org/licenses/>. */ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "ssol.h" #include "test_ssol_utils.h"