commit 8caf423f9fb2a4d6999ddb6df9f6924e24319857
parent 2ab949c58db797b4a53f02ccbcb4e1ee00146b2d
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Thu, 8 Nov 2018 11:24:20 +0100
Make the ground reflectivity configurable
Add the '-e' option to the CLI that defines the ground reflectivity.
Diffstat:
6 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/src/htrdr.c b/src/htrdr.c
@@ -505,8 +505,8 @@ htrdr_init
goto error;
}
- res = htrdr_ground_create
- (htrdr, args->filename_obj, args->repeat_ground, &htrdr->ground);
+ res = htrdr_ground_create(htrdr, args->filename_obj,
+ args->ground_reflectivity, args->repeat_ground, &htrdr->ground);
if(res != RES_OK) goto error;
proj_ratio =
diff --git a/src/htrdr_args.c b/src/htrdr_args.c
@@ -46,6 +46,9 @@ print_help(const char* cmd)
printf(
" -d dump octree data to OUTPUT wrt the VTK ASCII file format.\n");
printf(
+" -e ground reflectivity in [0, 1]. By default its value is `%g'.\n",
+ HTRDR_ARGS_DEFAULT.ground_reflectivity);
+ printf(
" -f overwrite the OUTPUT file if it already exists.\n");
printf(
" -g FILENAME path of an OBJ file representing the ground geometry.\n");
@@ -326,7 +329,7 @@ htrdr_args_init(struct htrdr_args* args, int argc, char** argv)
*args = HTRDR_ARGS_DEFAULT;
- while((opt = getopt(argc, argv, "a:C:c:D:dfGg:hi:m:o:RrT:t:v")) != -1) {
+ while((opt = getopt(argc, argv, "a:C:c:D:de:fGg:hi:m:o:RrT:t:v")) != -1) {
switch(opt) {
case 'a': args->filename_gas = optarg; break;
case 'C':
@@ -336,6 +339,12 @@ htrdr_args_init(struct htrdr_args* args, int argc, char** argv)
case 'c': args->filename_les = optarg; break;
case 'D': res = parse_sun_dir(args, optarg); break;
case 'd': args->dump_vtk = 1; break;
+ case 'e':
+ res = cstr_to_double(optarg, &args->ground_reflectivity);
+ if(args->ground_reflectivity < 0 || args->ground_reflectivity > 1) {
+ res = RES_BAD_ARG;
+ }
+ break;
case 'f': args->force_overwriting = 1; break;
case 'G': args->cache_grids = 1; break;
case 'g': args->filename_obj = optarg; break;
diff --git a/src/htrdr_args.h b/src/htrdr_args.h
@@ -47,6 +47,7 @@ struct htrdr_args {
double sun_azimuth; /* In degrees */
double sun_elevation; /* In degrees */
double optical_thickness; /* Threshold used during octree building */
+ double ground_reflectivity; /* Reflectivity of the ground */
unsigned nthreads; /* Hint on the number of threads to use */
int force_overwriting;
@@ -81,6 +82,7 @@ struct htrdr_args {
0, /* Sun azimuth */ \
90, /* Sun elevation */ \
1.0, /* Optical thickness */ \
+ 0.5, /* Ground reflectivity */ \
(unsigned)~0, /* #threads */ \
0, /* Force overwriting */ \
0, /* dump VTK */ \
diff --git a/src/htrdr_compute_radiance_sw.c b/src/htrdr_compute_radiance_sw.c
@@ -285,7 +285,8 @@ htrdr_compute_radiance_sw
CHK(RES_OK == ssf_phase_create
(&htrdr->lifo_allocators[ithread], &ssf_phase_rayleigh, &phase_rayleigh));
- SSF(lambertian_reflection_setup(bsdf, 0.5));
+ SSF(lambertian_reflection_setup
+ (bsdf, htrdr_ground_get_reflectivity(htrdr->ground)));
/* Setup the phase function for this spectral band & quadrature point */
g = htrdr_sky_fetch_particle_phase_function_asymmetry_parameter
diff --git a/src/htrdr_ground.c b/src/htrdr_ground.c
@@ -48,6 +48,7 @@ struct htrdr_ground {
struct s3d_scene_view* view;
float lower[3]; /* Ground lower bound */
float upper[3]; /* Ground upper bound */
+ double reflectivity;
int repeat; /* Make the ground infinite in X and Y */
struct htrdr* htrdr;
@@ -223,6 +224,7 @@ res_T
htrdr_ground_create
(struct htrdr* htrdr,
const char* obj_filename,
+ const double reflectivity,
const int repeat_ground, /* Infinitely repeat the ground in X and Y */
struct htrdr_ground** out_ground)
{
@@ -231,6 +233,7 @@ htrdr_ground_create
struct time t0, t1;
res_T res = RES_OK;
ASSERT(htrdr && obj_filename && out_ground);
+ ASSERT(reflectivity >= 0 || reflectivity <= 1);
ground = MEM_CALLOC(htrdr->allocator, 1, sizeof(*ground));
if(!ground) {
@@ -243,6 +246,7 @@ htrdr_ground_create
ref_init(&ground->ref);
ground->htrdr = htrdr;
ground->repeat = repeat_ground;
+ ground->reflectivity = reflectivity;
time_current(&t0);
res = setup_ground(ground, obj_filename);
@@ -276,6 +280,13 @@ htrdr_ground_ref_put(struct htrdr_ground* ground)
ref_put(&ground->ref, release_ground);
}
+double
+htrdr_ground_get_reflectivity(const struct htrdr_ground* ground)
+{
+ ASSERT(ground);
+ return ground->reflectivity;
+}
+
res_T
htrdr_ground_trace_ray
(struct htrdr_ground* ground,
diff --git a/src/htrdr_ground.h b/src/htrdr_ground.h
@@ -27,6 +27,7 @@ extern LOCAL_SYM res_T
htrdr_ground_create
(struct htrdr* htrdr,
const char* obj_filename,
+ const double reflectivity, /* In [0, 1] */
const int repeat_ground, /* Infinitely repeat the ground in X and Y */
struct htrdr_ground** ground);
@@ -38,6 +39,10 @@ extern LOCAL_SYM void
htrdr_ground_ref_put
(struct htrdr_ground* ground);
+extern LOCAL_SYM double
+htrdr_ground_get_reflectivity
+ (const struct htrdr_ground* ground);
+
extern LOCAL_SYM res_T
htrdr_ground_trace_ray
(struct htrdr_ground* ground,