From ba0e2bc4f4c493c805b187fc41107188d4a99ff7 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Wed, 2 Oct 2019 13:19:59 +0300
Subject: [PATCH] Colour normals wrt camera ray

---
 components/renderers/cpp/src/normals.cu       | 2 +-
 components/renderers/cpp/src/splat_render.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/components/renderers/cpp/src/normals.cu b/components/renderers/cpp/src/normals.cu
index 040f761b0..6ea8f7e1c 100644
--- a/components/renderers/cpp/src/normals.cu
+++ b/components/renderers/cpp/src/normals.cu
@@ -96,7 +96,7 @@ __global__ void vis_normals_kernel(ftl::cuda::TextureObject<float4> norm,
     if(x >= norm.width() || y >= norm.height()) return;
 
     output(x,y) = 0.0f;
-    float3 ray = make_float3(0.0f, 0.0f, 1.0f); //pose * camera.screenToCam(x,y,1.0f);
+    float3 ray = pose.getFloat3x3() * camera.screenToCam(x,y,1.0f);
     ray = ray / length(ray);
     float3 n = make_float3(norm.tex2D((int)x,(int)y));
     float l = length(n);
diff --git a/components/renderers/cpp/src/splat_render.cpp b/components/renderers/cpp/src/splat_render.cpp
index ceaff5325..2d93a6055 100644
--- a/components/renderers/cpp/src/splat_render.cpp
+++ b/components/renderers/cpp/src/splat_render.cpp
@@ -282,7 +282,7 @@ bool Splatter::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out, cuda
 		renderChannel(params, out, Channel::Normals, stream);
 
 		// Convert normal to single float value
-		ftl::cuda::normal_visualise(out.getTexture<float4>(Channel::Normals), temp_.getTexture<float>(Channel::Contribution), camera, params.m_viewMatrix, stream);
+		ftl::cuda::normal_visualise(out.getTexture<float4>(Channel::Normals), temp_.getTexture<float>(Channel::Contribution), camera, params.m_viewMatrixInverse, stream);
 
 		// Put in output as single float
 		cv::cuda::swap(temp_.get<GpuMat>(Channel::Contribution), out.create<GpuMat>(Channel::Normals));
-- 
GitLab