commit b823c1b1a83bbf3b476e3d7b76f641b2896b1607
parent 20f55008e47033e7e5a34ad16ce72dbf9d00863c
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 5 Apr 2017 18:09:10 +0200
On shading the tangent space normal in world space
This is actually wrong due to a wrong basis. One have to compute the
real tangent space basis instead.
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/solstice_material.c b/src/solstice_material.c
@@ -16,6 +16,7 @@
#include "solstice.h"
#include "solstice_c.h"
+#include <rsys/double33.h>
#include <rsys/image.h>
#include <solstice/ssol.h>
@@ -79,14 +80,17 @@ matte_get_normal
const double w[3],
double* val)
{
+ double basis[9];
double N[3];
const struct matte_param* param = ssol_param_buffer_get(buf);
(void)dev, (void)wavelength, (void)P, (void)Ng, (void)Ns, (void)uv, (void)w;
SSOL(image_sample(param->normal_map, SSOL_FILTER_NEAREST,
SSOL_ADDRESS_CLAMP, SSOL_ADDRESS_CLAMP, uv, N));
- /* TODO Transform in world space */
- d3_set(val, N);
+ d33_basis(basis, Ns);
+ d3_subd(N, d3_muld(N, N, 2), 1);
+ d33_muld3(N, basis, N);
+ d3_normalize(val, N);
}
static void