htrdr

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

commit 3261d022aa223904ef345c4788f8e635b02a46d2
parent 2ed9e2d029ab57811f294812b9abb2b6c271fd26
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Tue, 13 Oct 2020 12:38:05 +0200

Improve the reject sampling for the rectangle sensor

Diffstat:
Msrc/htrdr_sensor.c | 22++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/htrdr_sensor.c b/src/htrdr_sensor.c @@ -17,6 +17,7 @@ #include "htrdr.h" #include "htrdr_camera.h" #include "htrdr_ground.h" +#include "htrdr_interface.h" #include "htrdr_rectangle.h" #include "htrdr_sensor.h" @@ -77,8 +78,25 @@ sample_rectangle_ray * naïve "up" intersection. */ HTRDR(ground_trace_ray(ground, ray_org, up_dir, range, NULL, &hit)); - /* Reject the ray origin */ - if(!S3D_HIT_NONE(&hit)) return RES_BAD_OP; + /* Up direction is occluded, check if the sample must be recjected */ + if(!S3D_HIT_NONE(&hit)) { + struct htrdr_interface interf = HTRDR_INTERFACE_NULL; + const struct mrumtl* mat = NULL; + float wi[3]; + float N[3]; + + /* Fetch the interface of the hit */ + htrdr_ground_get_interface(ground, &hit, &interf); + + /* Retrieve the material on the side of the incident direction */ + f3_set_d3(wi, up_dir); + f3_normalize(N, hit.normal); + mat = f3_dot(wi, N) < 0 ? interf.mtl_front : interf.mtl_back; + + /* Mat is NULL only for the external air. Reject the sample if the material + * is not null, i.e. the incident direction travels into the geometry */ + if(mat != NULL) return RES_BAD_OP; + } /* Sample a ray direction */ htrdr_rectangle_get_normal(rect, normal);