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 7b2b81aa5f40ea71924e7eac6e61f817662edabd
parent cfb45d5b8e83d37ffd27f14b1ab24ac6413e6d44
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon, 12 Sep 2016 15:21:59 +0200

Fix and push further the ssf_bxdf test

Diffstat:
Msrc/test_ssf_bxdf.c | 54++++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 48 insertions(+), 6 deletions(-)

diff --git a/src/test_ssf_bxdf.c b/src/test_ssf_bxdf.c @@ -25,9 +25,12 @@ struct ALIGN(64) bxdf { uint32_t id; double u; double v; - double w[3]; + double wi[3]; + double wo[3]; double N[3]; double reflectivity; + double value; + double pdf; }; static res_T @@ -54,20 +57,50 @@ bxdf_sample (void* bxdf, const double u, const double v, - const double w[3], + const double wi[3], const double N[3], - double dir[4]) + double wo[4]) { struct bxdf* BxDF = bxdf; NCHECK(BxDF, NULL); CHECK(BxDF->u, u); CHECK(BxDF->v, v); - CHECK(d3_eq(BxDF->w, w), 1); + CHECK(d3_eq(BxDF->wi, wi), 1); CHECK(d3_eq(BxDF->N, N), 1); - d4(dir, 1.0, 2.0, 3.0, 4.0); + d4(wo, 1.0, 2.0, 3.0, 4.0); return BxDF->reflectivity; } +static double +bxdf_eval + (void* bxdf, + const double wi[3], + const double wo[3]) +{ + struct bxdf* BxDF = bxdf; + NCHECK(BxDF, NULL); + NCHECK(wi, NULL); + NCHECK(wo, NULL); + CHECK(d3_eq(BxDF->wi, wi), 1); + CHECK(d3_eq(BxDF->wo, wo), 1); + return BxDF->value; +} + +static double +bxdf_pdf + (void* bxdf, + const double wi[3], + const double wo[3]) +{ + struct bxdf* BxDF = bxdf; + NCHECK(BxDF, NULL); + NCHECK(wi, NULL); + NCHECK(wo, NULL); + CHECK(d3_eq(BxDF->wi, wi), 1); + CHECK(d3_eq(BxDF->wo, wo), 1); + return BxDF->pdf; +} + int main(int argc, char** argv) { @@ -85,6 +118,8 @@ main(int argc, char** argv) type.init = bxdf_init; type.release = bxdf_release; type.sample = bxdf_sample; + type.eval = bxdf_eval; + type.pdf = bxdf_pdf; type.sizeof_bxdf = sizeof(struct bxdf); type.alignof_bxdf = ALIGNOF(struct bxdf); @@ -140,7 +175,7 @@ main(int argc, char** argv) d3_normalize(w, d3(w, -1, -1, 0)); d3(N, 0.0, 1.0, 0.0); - d3_set(data->w, w); + d3_set(data->wi, w); d3_set(data->N, N); data->u = 0.0; data->v = 0.0; @@ -154,6 +189,13 @@ main(int argc, char** argv) data->reflectivity = 3.14; CHECK(ssf_bxdf_sample(bxdf, 0.5, 0.5, w, N, dir), 3.14); + d3_normalize(dir, dir); + d3_set(data->wo, dir); + data->value = 4.567; + CHECK(ssf_bxdf_eval(bxdf, w, dir), data->value); + data->pdf = 8.90; + CHECK(ssf_bxdf_pdf(bxdf, w, dir), data->pdf); + CHECK(bxdf_is_init, 1); CHECK(ssf_bxdf_ref_put(bxdf), RES_OK); CHECK(bxdf_is_init, 0);