star-sf

Set of surface and volume scattering functions
git clone git://git.meso-star.fr/star-sf.git
Log | Files | Refs | README | LICENSE

commit d622392b5b6253692c1c3868b657804f33ea8c9d
parent 2b0cd94bbbd91e913c797102ce40d52f395008f4
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon,  3 Oct 2016 16:42:24 +0200

Take into account the update of the SSP API

All SSP random variates use double rather than float.

Diffstat:
Msrc/ssf_lambertian_reflection.c | 8+++-----
Msrc/test_ssf_bsdf.c | 8+++-----
Msrc/test_ssf_utils.h | 12+++++-------
3 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/src/ssf_lambertian_reflection.c b/src/ssf_lambertian_reflection.c @@ -63,15 +63,13 @@ lambertian_reflection_sample double wi[3], double* pdf) { - float normal[3]; - float sample[4]; + double sample[4]; ASSERT(data && rng && wo && N && wi); ASSERT(d3_is_normalized(wo) && d3_is_normalized(N)); (void)wo; - f3_set_d3(normal, N); - ssp_ran_hemisphere_cos(rng, normal, sample); - d3_set_f3(wi, sample); + ssp_ran_hemisphere_cos(rng, N, sample); + d3_set(wi, sample); *pdf = sample[3]; return ((struct lambertian_reflection*)data)->reflectivity; } diff --git a/src/test_ssf_bsdf.c b/src/test_ssf_bsdf.c @@ -32,8 +32,7 @@ main(int argc, char** argv) double N[3]; double E, V, SE, R; double sum, sqr_sum; - float normal[3]; - float sample[3]; + double sample[4]; size_t i; (void)argc, (void)argv; @@ -83,9 +82,8 @@ main(int argc, char** argv) * totally wrong */ sum = 0; sqr_sum = 0; - f3_set_d3(normal, N); - ssp_ran_hemisphere_uniform(rng, normal, sample); - d3_set_f3(wo, sample); + ssp_ran_hemisphere_uniform(rng, N, sample); + d3_set(wo, sample); FOR_EACH(i, 0, NSTEPS) { double weight = ssf_bsdf_sample(bsdf, rng, wo, N, wi, &pdf); CHECK(ssf_bsdf_eval(bsdf, wo, N, wi), 0); diff --git a/src/test_ssf_utils.h b/src/test_ssf_utils.h @@ -184,12 +184,11 @@ check_microfacet_distribution struct ssp_rng* rng) { double N[3]; - float Nf[3]; const size_t NSTEPS = 10000; size_t i; size_t n; double wo[3]; - float sample[4]; + double sample[4]; double E, V, SE; double sum, sum2; @@ -198,9 +197,8 @@ check_microfacet_distribution N[2] = ssp_rng_uniform_double(rng, -1, 1); d3_normalize(N, N); - f3_set_d3(Nf, N); - ssp_ran_hemisphere_uniform(rng, Nf, sample); - d3_set_f3(wo, sample); + ssp_ran_hemisphere_uniform(rng, N, sample); + d3_set(wo, sample); /* Check that D(wh) is normalized wrt \int_{2PI} D(wh) |wh.n| dwh */ sum = sum2 = 0; @@ -208,8 +206,8 @@ check_microfacet_distribution do { FOR_EACH(i, 0, NSTEPS) { double wh[3], pdf, D, weight; - ssp_ran_hemisphere_cos(rng, Nf, sample); - d3_set_f3(wh, sample); + ssp_ran_hemisphere_cos(rng, N, sample); + d3_set(wh, sample); pdf = sample[3]; D = ssf_microfacet_distribution_eval(distrib, wo, N, wh); weight = D * d3_dot(wh, N) / pdf;