From dc22df215ac00fea9989e2c04e248ea11a9a9cd3 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Sat, 2 Nov 2019 21:45:39 +0200
Subject: [PATCH] Normalize output MLS normals

---
 applications/reconstruct/src/main.cpp | 4 +++-
 components/operators/src/smoothing.cu | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/applications/reconstruct/src/main.cpp b/applications/reconstruct/src/main.cpp
index f981494cb..553ac6665 100644
--- a/applications/reconstruct/src/main.cpp
+++ b/applications/reconstruct/src/main.cpp
@@ -247,11 +247,13 @@ static void run(ftl::Configurable *root) {
 
 	bool busy = false;
 
-	// Create the source depth map filters
+	// Create the source depth map pipeline
 	auto *prefilter = ftl::config::create<ftl::operators::Graph>(root, "pre_filters");
 	prefilter->append<ftl::operators::ColourChannels>("colour");
 	prefilter->append<ftl::operators::HFSmoother>("hfnoise");
+	// Smooth normals
 	prefilter->append<ftl::operators::SimpleMLS>("mls");
+	// Alignment
 
 	//auto *postfilter = ftl::config::create<ftl::Filters>(root, "post_filters");
 	//postfilter->create<ftl::filters::DepthSmoother>("hfnoise");
diff --git a/components/operators/src/smoothing.cu b/components/operators/src/smoothing.cu
index 903f90a19..0af17bf4b 100644
--- a/components/operators/src/smoothing.cu
+++ b/components/operators/src/smoothing.cu
@@ -68,7 +68,7 @@ using ftl::cuda::TextureObject;
     //    depth_out(screen.x,screen.y) = X.z;
 	//}
 	depth_out(x,y) = X.z;
-	normals_out(x,y) = make_float4(nX, 0.0f);
+	normals_out(x,y) = make_float4(nX / length(nX), 0.0f);
 }
 
 void ftl::cuda::mls_smooth(
-- 
GitLab