solstice-solver

Solver library of the solstice app
git clone git://git.meso-star.com/solstice-solver.git
Log | Files | Refs | README | LICENSE

commit f826be9a34552048d79f1eb0bf8e5785ab386909
parent 6fb46c1916722e11bba691394f154ada0123846f
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Fri,  2 Sep 2016 08:53:24 +0200

Fix the reflection vector in the sampling of the reflection BRDF

Diffstat:
Msrc/ssol_brdf_reflection.c | 9++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/ssol_brdf_reflection.c b/src/ssol_brdf_reflection.c @@ -34,15 +34,14 @@ reflection_sample float dir[4]) { struct brdf_reflection* reflection = data; - float vec[3], cosi; + float cosi; (void)rng; ASSERT(w && N && dir && f3_is_normalized(N) && f3_is_normalized(w) && data); /* Simply reflect the incoming direction w[3] with respect to the normal */ - f3_minus(vec, w); - cosi = f3_dot(vec, N); - f3_mulf(dir, N, cosi); - f3_sub(dir, vec, dir); + cosi = -f3_dot(w, N); + f3_mulf(dir, N, 2.f*cosi); + f3_add(dir, dir, w); dir[3] = 1.f; /* pdf */ return reflection->reflectivity; }