From f5bd6695d3c978f250918d262e2a5cd29ebbb1a2 Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Mon, 20 Jul 2020 20:26:35 +0300 Subject: [PATCH] Fixes for point cloud render --- components/renderers/cpp/src/CUDARender.cpp | 4 ++-- components/renderers/cpp/src/reprojection.cu | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/components/renderers/cpp/src/CUDARender.cpp b/components/renderers/cpp/src/CUDARender.cpp index 2f7533653..c72d3dace 100644 --- a/components/renderers/cpp/src/CUDARender.cpp +++ b/components/renderers/cpp/src/CUDARender.cpp @@ -184,7 +184,7 @@ void CUDARender::_dibr(ftl::rgbd::Frame &out, const Eigen::Matrix4d &t, cudaStre auto &f = scene_->frames[i].cast<ftl::rgbd::Frame>(); //auto *s = scene_->sources[i]; - if (f.has(Channel::Colour)) { + if (!f.has(Channel::Colour)) { LOG(ERROR) << "Missing required channel"; continue; } @@ -462,7 +462,7 @@ void CUDARender::_postprocessColours(ftl::rgbd::Frame &out) { params_.camera, stream_ ); - } else if (out.hasChannel(_getDepthChannel()) && out.hasChannel(out_chan_)) { + } else if (mesh_ && out.hasChannel(_getDepthChannel()) && out.hasChannel(out_chan_)) { ftl::cuda::fix_bad_colour( out.getTexture<float>(_getDepthChannel()), out.getTexture<uchar4>(out_chan_), diff --git a/components/renderers/cpp/src/reprojection.cu b/components/renderers/cpp/src/reprojection.cu index 023208cb2..e58ba6fa7 100644 --- a/components/renderers/cpp/src/reprojection.cu +++ b/components/renderers/cpp/src/reprojection.cu @@ -239,7 +239,7 @@ __global__ void reprojection_kernel( const float d = depth_in.tex2D((int)x, (int)y); if (d > params.camera.minDepth && d < params.camera.maxDepth) { //const float2 rpt = convertScreen<VPMODE>(params, x, y); - const float3 camPos = transform * params.camera.project<PROJECT>(make_float3(x, y, d)); + const float3 camPos = transform * params.camera.unproject<PROJECT>(make_float3(x, y, d)); if (camPos.z > camera.minDepth && camPos.z < camera.maxDepth) { const float3 screenPos = camera.project<Projection::PERSPECTIVE>(camPos); @@ -250,7 +250,8 @@ __global__ void reprojection_kernel( // Boolean match (0 or 1 weight). 1.0 if depths are sufficiently close float weight = depthMatching(params, camPos.z, d2); - weight *= float(weights.tex2D(int(screenPos.x+0.5f), int(screenPos.y+0.5f))) / 32767.0f; + if (params.m_flags & ftl::render::kUseWeightsChannel) + weight *= float(weights.tex2D(int(screenPos.x+0.5f), int(screenPos.y+0.5f))) / 32767.0f; const B output = make<B>(input); // * weight; //weightInput(input, weight); -- GitLab