commit 3a2eb821c809f2210c337a3539bf304d7f6cb522
parent 939426a3fb2c390daadce7bd1fa5c04253053c11
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Thu, 13 Oct 2016 10:14:04 +0200
Fix the "missing" MC integration
Diffstat:
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/ssol_solver.c b/src/ssol_solver.c
@@ -902,13 +902,13 @@ ssol_solve
float range[2] = { 0, FLT_MAX };
size_t id;
int depth = 0;
+ int hit_a_receiver = 0;
/* Sample a point into the scene view */
- S3D(scene_view_sample(view_samp,
- ssp_rng_canonical_float(rng),
- ssp_rng_canonical_float(rng),
- ssp_rng_canonical_float(rng),
- &prim, uv));
+ const float r1 = ssp_rng_canonical_float(rng);
+ const float r2 = ssp_rng_canonical_float(rng);
+ const float r3 = ssp_rng_canonical_float(rng);
+ S3D(scene_view_sample(view_samp, r1, r2, r3, &prim, uv));
/* Retrieve the position of the sampled point */
S3D(primitive_get_attrib(&prim, S3D_POSITION, uv, &attr));
@@ -1001,6 +1001,7 @@ ssol_solve
res = RES_IO_ERR;
goto error;
}
+ hit_a_receiver = 1;
}
if(mtl->type == MATERIAL_VIRTUAL) {
@@ -1071,7 +1072,7 @@ ssol_solve
ray_data.side_from = cos_dir_N < 0 ? SSOL_FRONT : SSOL_BACK;
}
- if(depth == 0) {
+ if(!hit_a_receiver) {
estimator->missing.weight += weight;
estimator->missing.sqr_weight += weight*weight;
}