htrdr

Solving radiative transfer in heterogeneous media
git clone git://git.meso-star.fr/htrdr.git
Log | Files | Refs | README | LICENSE

commit 1d7495104fac18b7825c832e3afa94d71ef743cf
parent 19160f8ba423fcc764a8dad777e3f65a352bbce1
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Sat,  7 Mar 2020 14:06:48 +0100

Fix several issues on handling the ground materials

Diffstat:
Msrc/htrdr.c | 1+
Msrc/htrdr_args.c | 1+
Msrc/htrdr_compute_radiance_sw.c | 5++++-
Msrc/htrdr_interface.c | 7++++---
Msrc/htrdr_mtl.c | 2+-
5 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/htrdr.c b/src/htrdr.c @@ -521,6 +521,7 @@ htrdr_release(struct htrdr* htrdr) if(htrdr->sun) htrdr_sun_ref_put(htrdr->sun); if(htrdr->cam) htrdr_camera_ref_put(htrdr->cam); if(htrdr->buf) htrdr_buffer_ref_put(htrdr->buf); + if(htrdr->mtl) htrdr_mtl_ref_put(htrdr->mtl); if(htrdr->lifo_allocators) { size_t i; FOR_EACH(i, 0, htrdr->nthreads) { diff --git a/src/htrdr_args.c b/src/htrdr_args.c @@ -399,6 +399,7 @@ htrdr_args_init(struct htrdr_args* args, int argc, char** argv) res = parse_multiple_parameters (args, optarg, parse_image_parameter); break; + case 'M': args->filename_mtl = optarg; break; case 'm': args->filename_mie = optarg; break; case 'O': args->cache = optarg; break; case 'o': args->output = optarg; break; diff --git a/src/htrdr_compute_radiance_sw.c b/src/htrdr_compute_radiance_sw.c @@ -411,6 +411,9 @@ htrdr_compute_radiance_sw R = ssf_bsdf_eval(bsdf, wo, N, sun_dir) * d3_dot(N, sun_dir); } + /* Release the BSDF */ + SSF(bsdf_ref_put(bsdf)); + /* Scattering in the medium */ } else { struct ssf_phase* phase; @@ -418,7 +421,7 @@ htrdr_compute_radiance_sw double ks_gas; /* Scattering coefficient of the gaz */ double ks; /* Overall scattering coefficient */ - ks_gas = htsky_fetch_raw_property(htrdr->sky, HTSKY_Ks, + ks_gas = htsky_fetch_raw_property(htrdr->sky, HTSKY_Ks, HTSKY_CPNT_FLAG_GAS, iband, iquad, pos_next, -DBL_MAX, DBL_MAX); ks_particle = htsky_fetch_raw_property(htrdr->sky, HTSKY_Ks, HTSKY_CPNT_FLAG_PARTICLES, iband, iquad, pos_next, -DBL_MAX, DBL_MAX); diff --git a/src/htrdr_interface.c b/src/htrdr_interface.c @@ -117,15 +117,16 @@ htrdr_interface_create_bsdf double N[3]; res_T res = RES_OK; ASSERT(htrdr && pos && hit && out_bsdf); - ASSERT(interf && interf->mtl_front && interf->mtl_back); + ASSERT(interf && (interf->mtl_front || interf->mtl_back)); ASSERT(htrdr && interf && pos && dir && hit && out_bsdf); ASSERT(d3_is_normalized(dir)); - /* Check incoming ray */ d3_normalize(N, d3_set_f3(N, hit->normal)); + + /* Retrieve the brdf of the material on the other side of the hit side */ if(d3_dot(N, dir) < 0) { - mat = interf->mtl_front; + mat = interf->mtl_back; } else { mat = interf->mtl_back; } diff --git a/src/htrdr_mtl.c b/src/htrdr_mtl.c @@ -189,7 +189,7 @@ htrdr_mtl_create { struct htrdr_mtl* mtl = NULL; res_T res = RES_OK; - ASSERT(htrdr && filename && mtl); + ASSERT(htrdr && filename && out_mtl); mtl = MEM_CALLOC(htrdr->allocator, 1, sizeof(*mtl)); if(!mtl) {