commit 389c9fe6811e0655d250048eeb8f88cd1dcde86c
parent f55954dc9d84e50d4d41206923e1d599c61280dc
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 8 Mar 2017 14:14:16 +0100
Handle the punched surface normal in the path-tracing integrator
Diffstat:
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/ssol_draw_pt.c b/src/ssol_draw_pt.c
@@ -19,6 +19,7 @@
#include "ssol_material_c.h"
#include "ssol_object_c.h"
#include "ssol_scene_c.h"
+#include "ssol_shape_c.h"
#include "ssol_sun_c.h"
#include <rsys/double2.h>
@@ -158,11 +159,16 @@ Li
d3_set_f3(o, ray_org);
d3_set_f3(wo, ray_dir);
d2_set_f2(uv, hit.uv);
- d3_set_f3(N, hit.normal);
- d3_normalize(N, N);
d3_normalize(wo, wo);
- if(f3_dot(hit.normal, ray_dir) < 0) {
+ /* Retrieve and normalized the hit normal */
+ switch(sshape->shape->type) {
+ case SHAPE_MESH: d3_normalize(N, d3_set_f3(N, hit.normal)); break;
+ case SHAPE_PUNCHED: d3_normalize(N, ray_data.N); break;
+ default: FATAL("Unreachable code"); break;
+ }
+
+ if(d3_dot(N, wo) < 0) {
mtl = sshape->mtl_front;
side = SSOL_FRONT;
} else {