htrdr

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

commit 59fde9035d6ae2b725eeabfba1208566053e8a86
parent a535d68dc5bdaa31ac36feed38a026ba4d89e4aa
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Tue, 19 Mar 2019 10:24:16 +0100

Merge branch 'release_0.0.4'

Diffstat:
MREADME.md | 12++++++++++++
Mcmake/CMakeLists.txt | 2+-
Msrc/htrdr.c | 4+++-
Msrc/htrdr_compute_radiance_sw.c | 10++++++----
4 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/README.md b/README.md @@ -60,6 +60,18 @@ informations on CMake. ## Release notes +### Version 0.0.4 + +- Fix the computation of the surface scattering: there was a bug in how Russian + roulette was implemented at surface scattering leading to an underestimation + of the surface reflection. +- Update the thread allocation policy: by default, the number of threads is now + defined as the maximum between the number of processors detected by OpenMP + and the number of threads defined by the `OMP_NUM_THREADS` environment + variable. This variable can be used to counteract the number of processors + detected by OpenMP that can be lower than the real number of processors of + the system. + ### Version 0.0.3 - Fix compilation on systems with a GNU C Library whose version is less than diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -60,7 +60,7 @@ include_directories( ################################################################################ set(VERSION_MAJOR 0) set(VERSION_MINOR 0) -set(VERSION_PATCH 3) +set(VERSION_PATCH 4) set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) set(HTRDR_ARGS_DEFAULT_CAMERA_POS "0,0,0") diff --git a/src/htrdr.c b/src/htrdr.c @@ -437,6 +437,7 @@ htrdr_init double sun_dir[3]; const char* output_name = NULL; size_t ithread; + int nthreads_max; res_T res = RES_OK; ASSERT(args && htrdr); @@ -451,10 +452,11 @@ htrdr_init str_init(htrdr->allocator, &htrdr->output_name); + nthreads_max = MMAX(omp_get_max_threads(), omp_get_num_procs()); htrdr->dump_vtk = args->dump_vtk; htrdr->cache_grids = args->cache_grids; htrdr->verbose = args->verbose; - htrdr->nthreads = MMIN(args->nthreads, (unsigned)omp_get_num_procs()); + htrdr->nthreads = MMIN(args->nthreads, (unsigned)nthreads_max); htrdr->spp = args->image.spp; htrdr->width = args->image.definition[0]; htrdr->height = args->image.definition[1]; diff --git a/src/htrdr_compute_radiance_sw.c b/src/htrdr_compute_radiance_sw.c @@ -325,6 +325,7 @@ htrdr_compute_radiance_sw /* Radiative random walk */ for(;;) { struct scattering_context scattering_ctx = SCATTERING_CONTEXT_NULL; + double bounce_reflectivity = 0; /* Find the first intersection with a surface */ d2(range, 0, DBL_MAX); @@ -388,16 +389,14 @@ htrdr_compute_radiance_sw /* Scattering at a surface */ if(SVX_HIT_NONE(&svx_hit)) { - double reflectivity; double N[3]; int type; d3_normalize(N, d3_set_f3(N, s3d_hit.normal)); if(d3_dot(N, wo) < 0) d3_minus(N, N); - reflectivity = ssf_bsdf_sample - (bsdf, rng, wo, N, dir_next, &type, &pdf); - if(ssp_rng_canonical(rng) > reflectivity) break; /* Russian roulette */ + bounce_reflectivity = ssf_bsdf_sample + (bsdf, rng, wo, N, dir_next, &type, &pdf); if(d3_dot(N, sun_dir) < 0) { /* Below the ground */ R = 0; } else { @@ -432,6 +431,9 @@ htrdr_compute_radiance_sw ksi *= Tr_abs; w += ksi * L_sun * sun_solid_angle * Tr * R; + /* Russian roulette */ + if(ssp_rng_canonical(rng) >= bounce_reflectivity) break; + /* Setup the next random walk state */ d3_set(pos, pos_next); d3_set(dir, dir_next);