diff --git a/components/renderers/cpp/include/ftl/render/splat_params.hpp b/components/renderers/cpp/include/ftl/render/splat_params.hpp index 4f9c8882b161d7774388e8d9fff7337cb1d6e685..5bd7d2edbc0b30863e5ecfe04f2e7bc0ce662f20 100644 --- a/components/renderers/cpp/include/ftl/render/splat_params.hpp +++ b/components/renderers/cpp/include/ftl/render/splat_params.hpp @@ -8,7 +8,7 @@ namespace ftl { namespace render { -static const uint kShowBlockBorders = 0x00000001; // Deprecated: from voxels system +static const uint kShowDisconMask = 0x00000001; static const uint kNoSplatting = 0x00000002; static const uint kNoUpsampling = 0x00000004; static const uint kNoTexturing = 0x00000008; diff --git a/components/renderers/cpp/src/splat_render.cpp b/components/renderers/cpp/src/splat_render.cpp index 24afd49a65c8c964b57643cf593094581bdf23c4..6635d1ab4295d708fef458214e613d0c554f03b4 100644 --- a/components/renderers/cpp/src/splat_render.cpp +++ b/components/renderers/cpp/src/splat_render.cpp @@ -224,9 +224,10 @@ bool Splatter::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out, cuda // Parameters object to pass to CUDA describing the camera SplatParams params; params.m_flags = 0; - if (src->value("splatting", true) == false) params.m_flags |= ftl::render::kNoSplatting; - if (src->value("upsampling", true) == false) params.m_flags |= ftl::render::kNoUpsampling; - if (src->value("texturing", true) == false) params.m_flags |= ftl::render::kNoTexturing; + if (src->value("show_discontinuity_mask", false)) params.m_flags |= ftl::render::kShowDisconMask; + //if (src->value("splatting", true) == false) params.m_flags |= ftl::render::kNoSplatting; + //if (src->value("upsampling", true) == false) params.m_flags |= ftl::render::kNoUpsampling; + //if (src->value("texturing", true) == false) params.m_flags |= ftl::render::kNoTexturing; params.m_viewMatrix = MatrixConversion::toCUDA(src->getPose().cast<float>().inverse()); params.m_viewMatrixInverse = MatrixConversion::toCUDA(src->getPose().cast<float>()); params.camera = camera; diff --git a/components/renderers/cpp/src/splatter.cu b/components/renderers/cpp/src/splatter.cu index 41777d49d4a35888f297bc14bfc9c99d034ee67c..de3902b6c2471099f6aeca47d99d680e825aa288 100644 --- a/components/renderers/cpp/src/splatter.cu +++ b/components/renderers/cpp/src/splatter.cu @@ -25,7 +25,7 @@ using ftl::render::SplatParams; const int y = blockIdx.y*blockDim.y + threadIdx.y; const float4 worldPos = points.tex2D(x, y); - if (worldPos.x == MINF || worldPos.w < 0.0f) return; + if (worldPos.x == MINF || (!(params.m_flags & ftl::render::kShowDisconMask) && worldPos.w < 0.0f)) return; // Find the virtual screen position of current point const float3 camPos = params.m_viewMatrix * make_float3(worldPos); @@ -84,12 +84,12 @@ __global__ void dibr_attribute_contrib_kernel( const int x = (blockIdx.x*blockDim.x + threadIdx.x) / WARP_SIZE; const int y = blockIdx.y*blockDim.y + threadIdx.y; - const float3 worldPos = make_float3(points.tex2D(x, y)); + const float4 worldPos = points.tex2D(x, y); //const float3 normal = make_float3(tex2D<float4>(camera.normal, x, y)); if (worldPos.x == MINF) return; //const float r = (camera.poseInverse * worldPos).z / camera.params.fx; - const float3 camPos = params.m_viewMatrix * worldPos; + const float3 camPos = params.m_viewMatrix * make_float3(worldPos); if (camPos.z < params.camera.minDepth) return; if (camPos.z > params.camera.maxDepth) return; const uint2 screenPos = params.camera.camToScreen<uint2>(camPos); @@ -103,8 +103,9 @@ __global__ void dibr_attribute_contrib_kernel( const float d = ((float)depth_in.tex2D((int)screenPos.x, (int)screenPos.y)/1000.0f); //if (abs(d - camPos.z) > DEPTH_THRESHOLD) return; - // TODO:(Nick) Should just one thread load these to shared mem? - const float4 colour = make_float4(colour_in.tex2D(x, y)); + const float4 colour = (params.m_flags & ftl::render::kShowDisconMask && worldPos.w < 0.0f) ? + make_float4(0.0f,0.0f,255.0f,255.0f) : + make_float4(colour_in.tex2D(x, y)); //const float4 normal = tex2D<float4>(camera.normal, x, y); // Each thread in warp takes an upsample point and updates corresponding depth buffer.