diff --git a/components/renderers/cpp/src/normals.cu b/components/renderers/cpp/src/normals.cu index 14357d02ed00f212577e463051d315e6e5a90078..d462fca2a070279ff1d87d7933bae94045e7cc3c 100644 --- a/components/renderers/cpp/src/normals.cu +++ b/components/renderers/cpp/src/normals.cu @@ -226,7 +226,9 @@ void ftl::cuda::normals(ftl::cuda::TextureObject<float4> &output, switch (radius) { case 7: smooth_normals_kernel<7><<<gridSize, blockSize, 0, stream>>>(temp, output, input, camera, pose, smoothing); case 5: smooth_normals_kernel<5><<<gridSize, blockSize, 0, stream>>>(temp, output, input, camera, pose, smoothing); - case 3: smooth_normals_kernel<3><<<gridSize, blockSize, 0, stream>>>(temp, output, input, camera, pose, smoothing); + case 3: smooth_normals_kernel<3><<<gridSize, blockSize, 0, stream>>>(temp, output, input, camera, pose, smoothing); + case 2: smooth_normals_kernel<2><<<gridSize, blockSize, 0, stream>>>(temp, output, input, camera, pose, smoothing); + case 1: smooth_normals_kernel<1><<<gridSize, blockSize, 0, stream>>>(temp, output, input, camera, pose, smoothing); } cudaSafeCall( cudaGetLastError() ); diff --git a/components/renderers/cpp/src/splat_render.cpp b/components/renderers/cpp/src/splat_render.cpp index 64d987c1026dd59255a94b7d5e17d09704829946..9de1f00b8725f30a1dbc9660587e3d02148213df 100644 --- a/components/renderers/cpp/src/splat_render.cpp +++ b/components/renderers/cpp/src/splat_render.cpp @@ -403,7 +403,7 @@ bool Splatter::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out) { temp_.create<GpuMat>(Channel::Contribution, Format<float>(camera.width, camera.height)); temp_.create<GpuMat>(Channel::Depth, Format<int>(camera.width, camera.height)); temp_.create<GpuMat>(Channel::Depth2, Format<int>(camera.width, camera.height)); - temp_.create<GpuMat>(Channel::Normals, Format<float4>(g.cols, g.rows)); + temp_.create<GpuMat>(Channel::Normals, Format<float4>(camera.width, camera.height)); //g.cols, g.rows)); cv::cuda::Stream cvstream = cv::cuda::StreamAccessor::wrapStream(stream_); @@ -429,7 +429,7 @@ bool Splatter::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out) { //temp_.get<GpuMat>(Channel::Normals).setTo(cv::Scalar(0.0f,0.0f,0.0f,0.0f), cvstream); // First make sure each input has normals - temp_.createTexture<float4>(Channel::Normals); + /*temp_.createTexture<float4>(Channel::Normals); for (int i=0; i<scene_->frames.size(); ++i) { auto &f = scene_->frames[i]; auto s = scene_->sources[i]; @@ -474,7 +474,7 @@ bool Splatter::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out) { ftl::cuda::normal_filter(f.getTexture<float4>(Channel::Normals), f.getTexture<float4>(Channel::Points), s->parameters(), pose, norm_filter_, stream_); } } - } + }*/ Channel chan = src->getChannel(); @@ -500,30 +500,40 @@ bool Splatter::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out) { return true; } + // Create and render triangles for depth _dibr(stream_); + + // Generate normals + ftl::cuda::normals(accum_.createTexture<float4>(Channel::Normals, Format<float4>(camera.width, camera.height)), + temp_.createTexture<float4>(Channel::Normals), + temp_.getTexture<int>(Channel::Depth2), + 1, 0.02f, + params_.camera, params_.m_viewMatrix.getFloat3x3(), params_.m_viewMatrixInverse.getFloat3x3(), stream_); + _renderChannel(out, Channel::Colour, Channel::Colour, stream_); if (chan == Channel::Depth) { - LOG(INFO) << "Copying depth"; + //LOG(INFO) << "Copying depth"; temp_.get<GpuMat>(Channel::Depth2).convertTo(out.get<GpuMat>(Channel::Depth), CV_32F, 1.0f / 1000.0f, cvstream); - LOG(INFO) << "DEPTH COPIED"; + //LOG(INFO) << "DEPTH COPIED"; } else if (chan == Channel::Normals) { - out.create<GpuMat>(Channel::Normals, Format<float4>(camera.width, camera.height)); + //out.create<GpuMat>(Channel::Normals, Format<uchar4>(camera.width, camera.height)); // Render normal attribute - _renderChannel(out, Channel::Normals, Channel::Normals, stream_); + //_renderChannel(out, Channel::Normals, Channel::Normals, stream_); // Convert normal to single float value - temp_.create<GpuMat>(Channel::Colour, Format<uchar4>(camera.width, camera.height)).setTo(cv::Scalar(0,0,0,0), cvstream); - ftl::cuda::normal_visualise(out.getTexture<float4>(Channel::Normals), temp_.createTexture<uchar4>(Channel::Colour), + + out.create<GpuMat>(Channel::Normals, Format<uchar4>(camera.width, camera.height)).setTo(cv::Scalar(0,0,0,0), cvstream); + ftl::cuda::normal_visualise(accum_.getTexture<float4>(Channel::Normals), out.createTexture<uchar4>(Channel::Normals), light_pos_, light_diffuse_, light_ambient_, stream_); // Put in output as single float - cv::cuda::swap(temp_.get<GpuMat>(Channel::Colour), out.create<GpuMat>(Channel::Normals)); - out.resetTexture(Channel::Normals); + //cv::cuda::swap(temp_.get<GpuMat>(Channel::Colour), out.get<GpuMat>(Channel::Normals)); + //out.resetTexture(Channel::Normals); } //else if (chan == Channel::Contribution) //{