commit 4bb5932da14a11d198451cfcdeeba8c8ea488df4
parent b8ff59859a7f002d549f165c79e85ff3ebca84d0
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 31 May 2017 15:15:19 +0200
Fix when the sampled starting point lies into a dielectric material
The first vertex of a radiative path is assumed to lie in the
surrounding medium. This may be actually wrong if the starting point is
sampled on a geometry with a dielectric material. Indeed, the side of
the sampled face is defined in order to ensure that the sampled point
looks toward the sun and thus the starting point can lie on the internal
side of the dielectric geometry. In this case, this point lies in the
internal medium of the geometry and not in the surrounding medium.
This commit ensures that the starting medium is the correct one in order
to ensure that the media consistency tests do not fail.
Diffstat:
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/ssol_material.c b/src/ssol_material.c
@@ -724,6 +724,7 @@ material_get_next_medium
if(media_ceq(&mtl->out_medium, medium)) {
ssol_medium_copy(next_medium, &mtl->in_medium);
} else {
+ ASSERT(media_ceq(&mtl->in_medium, medium));
ssol_medium_copy(next_medium, &mtl->out_medium);
}
break;
diff --git a/src/ssol_solver.c b/src/ssol_solver.c
@@ -746,7 +746,7 @@ trace_radiative_path
view_samp, view_rt, ran_sun_dir, ran_sun_wl, thread_ctx->rng, &is_lit);
if(res != RES_OK) goto error;
- if(tracker) {
+if(tracker) {
/* Add the first point of the starting segment */
if(tracker->sun_ray_length > 0) {
double pos[3], wi[3];
@@ -774,9 +774,20 @@ trace_radiative_path
ACCUM_WEIGHT(thread_ctx->shadowed, pt.weight);
if(tracker) path.type = SSOL_PATH_SHADOW;
} else {
- if(scn->atmosphere) {
- ssol_data_copy(&medium.absorption, &scn->atmosphere->absorption);
+ struct ssol_material* mtl = point_get_material(&pt);
+
+ /* Define the medium in which the sampled point lies */
+ switch(mtl->type) {
+ case SSOL_MATERIAL_DIELECTRIC:
+ case SSOL_MATERIAL_THIN_DIELECTRIC:
+ ssol_medium_copy(&medium, &mtl->out_medium);
+ break;
+ default:
+ if(scn->atmosphere)
+ ssol_data_copy(&medium.absorption, &scn->atmosphere->absorption);
+ break;
}
+
/* Setup the ray as if it starts from the current point position in order
* to handle the points that start from a virtual material */
f3_set_d3(org, pt.pos);
@@ -785,7 +796,6 @@ trace_radiative_path
for(;;) { /* Here we go for the radiative random walk */
struct ray_data ray_data = RAY_DATA_NULL;
- struct ssol_material* mtl;
double absorption;
/* Compute interaction with material */