Skip to content
Snippets Groups Projects
Commit 205b2014 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Use point density

parent b7e0468d
No related branches found
No related tags found
1 merge request!123Implements #189 using density to estimate radius
Pipeline #15140 passed
This commit is part of merge request !123. Comments created here will be created in the context of that merge request.
......@@ -259,6 +259,7 @@ void Splatter::_renderChannel(
if (is_4chan) {
ftl::cuda::splat(
accum_.getTexture<float4>(Channel::Normals),
accum_.getTexture<float>(Channel::Density),
accum_.getTexture<float4>(channel_out),
temp_.getTexture<int>(Channel::Depth2),
out.createTexture<float>(Channel::Depth),
......@@ -268,6 +269,7 @@ void Splatter::_renderChannel(
} else if (is_float) {
ftl::cuda::splat(
accum_.getTexture<float4>(Channel::Normals),
accum_.getTexture<float>(Channel::Density),
accum_.getTexture<float>(channel_out),
temp_.getTexture<int>(Channel::Depth2),
out.createTexture<float>(Channel::Depth),
......@@ -277,6 +279,7 @@ void Splatter::_renderChannel(
} else {
ftl::cuda::splat(
accum_.getTexture<float4>(Channel::Normals),
accum_.getTexture<float>(Channel::Density),
accum_.getTexture<uchar4>(channel_out),
temp_.getTexture<int>(Channel::Depth2),
out.createTexture<float>(Channel::Depth),
......
......@@ -150,6 +150,7 @@ __device__ inline float make(float v) {
__global__ void splat_kernel(
//TextureObject<float4> points, // Original 3D points
TextureObject<float4> normals,
TextureObject<float> density,
TextureObject<T> in,
TextureObject<int> depth_in, // Virtual depth map
TextureObject<float> depth_out, // Accumulated output
......@@ -205,7 +206,7 @@ __device__ inline float make(float v) {
// Assumed to be normalised
float4 n = normals.tex2D((int)(x+u), (int)(y+v));
float4 n = normals.tex2D((int)(x)+u, (int)(y)+v);
n /= length(n);
//if (length(make_float3(n)) == 0.0f) printf("BAD NORMAL\n");
......@@ -215,7 +216,8 @@ __device__ inline float make(float v) {
if (r != PINF) { //} && fabs(t-camPos.z) < 0.01f) {
// Adjust from normalised ray back to original meters units
t *= scale;
float weight = ftl::cuda::weighting(r, 2.0f/params.camera.fx); // (1.0f/params.camera.fx) / (t/params.camera.fx)
const float dens = density.tex2D((int)(x)+u, (int)(y)+v);
float weight = ftl::cuda::weighting(r, dens/params.camera.fx); // (1.0f/params.camera.fx) / (t/params.camera.fx)
/* Buehler C. et al. 2001. Unstructured Lumigraph Rendering. */
/* Orts-Escolano S. et al. 2016. Holoportation: Virtual 3D teleportation in real-time. */
......@@ -269,6 +271,7 @@ __device__ inline float make(float v) {
template <typename T>
void ftl::cuda::splat(
TextureObject<float4> &normals,
TextureObject<float> &density,
TextureObject<T> &colour_in,
TextureObject<int> &depth_in, // Virtual depth map
TextureObject<float> &depth_out,
......@@ -279,6 +282,7 @@ void ftl::cuda::splat(
splat_kernel<8,T><<<gridSize, blockSize, 0, stream>>>(
normals,
density,
colour_in,
depth_in,
depth_out,
......@@ -290,6 +294,7 @@ void ftl::cuda::splat(
template void ftl::cuda::splat<uchar4>(
TextureObject<float4> &normals,
TextureObject<float> &density,
TextureObject<uchar4> &colour_in,
TextureObject<int> &depth_in, // Virtual depth map
TextureObject<float> &depth_out,
......@@ -298,6 +303,7 @@ template void ftl::cuda::splat<uchar4>(
template void ftl::cuda::splat<float4>(
TextureObject<float4> &normals,
TextureObject<float> &density,
TextureObject<float4> &colour_in,
TextureObject<int> &depth_in, // Virtual depth map
TextureObject<float> &depth_out,
......@@ -306,6 +312,7 @@ template void ftl::cuda::splat<float4>(
template void ftl::cuda::splat<float>(
TextureObject<float4> &normals,
TextureObject<float> &density,
TextureObject<float> &colour_in,
TextureObject<int> &depth_in, // Virtual depth map
TextureObject<float> &depth_out,
......
......@@ -17,6 +17,7 @@ namespace cuda {
template <typename T>
void splat(
ftl::cuda::TextureObject<float4> &normals,
ftl::cuda::TextureObject<float> &density,
ftl::cuda::TextureObject<T> &colour_in,
ftl::cuda::TextureObject<int> &depth_in, // Virtual depth map
ftl::cuda::TextureObject<float> &depth_out,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment