From d3fb2ac0befe6d3a10155cfebc26e00071953b15 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Wed, 2 Oct 2019 14:30:54 +0300
Subject: [PATCH] Don't create normals for bad points

---
 components/renderers/cpp/src/normals.cu | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/components/renderers/cpp/src/normals.cu b/components/renderers/cpp/src/normals.cu
index 0a4c12ae8..ad6c34cf4 100644
--- a/components/renderers/cpp/src/normals.cu
+++ b/components/renderers/cpp/src/normals.cu
@@ -20,14 +20,14 @@ __global__ void computeNormals_kernel(ftl::cuda::TextureObject<float4> output,
 		const float3 MC = make_float3(input.tex2D((int)x+0, (int)y-1)); //[(y-1)*width+(x+0)];
 		const float3 CM = make_float3(input.tex2D((int)x-1, (int)y+0)); //[(y+0)*width+(x-1)];
 
-		//if(CC.x != MINF && PC.x != MINF && CP.x != MINF && MC.x != MINF && CM.x != MINF) {
+		if(CC.x != MINF) { // && PC.x != MINF && CP.x != MINF && MC.x != MINF && CM.x != MINF) {
 			const float3 n = cross(PC-MC, CP-CM);
 			const float  l = length(n);
 
 			if(l > 0.0f) {
 				output(x,y) = make_float4(n/-l, 1.0f);
 			}
-		//}
+		}
 	}
 }
 
@@ -51,6 +51,7 @@ __global__ void smooth_normals_kernel(ftl::cuda::TextureObject<float4> norms,
             const float3 p = make_float3(points.tex2D((int)x+u,(int)y+v));
             if (p.x == MINF) continue;
             const float s = ftl::cuda::spatialWeighting(p0, p, smoothing);
+            //const float s = 1.0f;
 
             if (s > 0.0f) {
                 const float4 n = norms.tex2D((int)x+u,(int)y+v);
-- 
GitLab