From 00b29d650b25d96c58d387eed6bf6a9d9b3b7588 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Wed, 13 Nov 2019 17:18:09 +0200
Subject: [PATCH] Anti alias right texture and use bilinear

---
 components/operators/src/antialiasing.cpp   | 7 +++++++
 components/operators/src/antialiasing.cu    | 1 +
 components/renderers/cpp/src/tri_render.cpp | 1 +
 3 files changed, 9 insertions(+)

diff --git a/components/operators/src/antialiasing.cpp b/components/operators/src/antialiasing.cpp
index d3c63ce1b..575cc26a5 100644
--- a/components/operators/src/antialiasing.cpp
+++ b/components/operators/src/antialiasing.cpp
@@ -18,5 +18,12 @@ bool FXAA::apply(ftl::rgbd::Frame &in, ftl::rgbd::Frame &out, ftl::rgbd::Source
 		stream
 	);
 
+	if (in.hasChannel(Channel::Right)) {
+		ftl::cuda::fxaa(
+			in.getTexture<uchar4>(Channel::Right),
+			stream
+		);
+	}
+
 	return true;
 }
diff --git a/components/operators/src/antialiasing.cu b/components/operators/src/antialiasing.cu
index f0b64bd89..7ad851a2a 100644
--- a/components/operators/src/antialiasing.cu
+++ b/components/operators/src/antialiasing.cu
@@ -71,6 +71,7 @@ __global__ void filter_fxaa2(ftl::cuda::TextureObject<uchar4> data) {
 
     //surf2Dwrite<uchar4>(out_color, surfaceWrite, x*sizeof(uchar4), y);
 
+	// FIXME: Should not output to same texture object.
     data(x,y) = out_color;
 }
 
diff --git a/components/renderers/cpp/src/tri_render.cpp b/components/renderers/cpp/src/tri_render.cpp
index 7998cae17..5aa6e7df2 100644
--- a/components/renderers/cpp/src/tri_render.cpp
+++ b/components/renderers/cpp/src/tri_render.cpp
@@ -628,6 +628,7 @@ bool Triangular::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out) {
 		
 		out.create<GpuMat>(Channel::Right, Format<uchar4>(camera.width, camera.height));
 		out.get<GpuMat>(Channel::Right).setTo(background_, cvstream);
+		out.createTexture<uchar4>(Channel::Right, true);
 
 		// Need to re-dibr due to pose change
 		if (mesh_) {
-- 
GitLab