commit c116b67b0b45168552d0f6a9b9af4ca335a2510e
parent 7422dac33428476df21645230bfd54cabd777fba
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Fri, 25 Sep 2015 16:20:25 +0200
Fix the sampling of the starting position of the radiative path
Canonical random numbers are casted from double to float leading to
numbers equals to 1 while they must lie in [0, 1).
Diffstat:
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/sgf_estimator.c b/src/sgf_estimator.c
@@ -101,6 +101,7 @@ gebhart_radiative_path
float pos[3]; /* Radiative path position */
float dir[4]; /* Radiative path direction. dir[3] <=> sampled dir pdf */
float range[2]; /* Traced ray range */
+ float u, v;
/* Discard faces with no emissivity */
emissivity = desc->get_material_property(desc->material,
@@ -115,8 +116,10 @@ gebhart_radiative_path
/* Uniformly sample the primitive to define the starting position of the
* radiative path */
- S3D(primitive_sample(&prim,
- (float)ssp_rng_canonical(rng), (float)ssp_rng_canonical(rng), st));
+ do { u = (float)ssp_rng_canonical(rng); } while(u >= 1.f);
+ do { v = (float)ssp_rng_canonical(rng); } while(u >= 1.f);
+
+ S3D(primitive_sample(&prim, u, v, st));
S3D(primitive_get_attrib(&prim, S3D_POSITION, st, &attrib));
f3_set(pos, attrib.value);