Skip to content
Snippets Groups Projects

Implements #189 using density to estimate radius

Merged Nicolas Pope requested to merge feature/189/splatradius into master
3 files
+ 20
18
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -57,7 +57,7 @@ __global__ void computeNormals_kernel(ftl::cuda::TextureObject<float4> output,
const float l = length(n);
if(l > 0.0f) {
output(x,y) = make_float4(pose * (n/-l), 1.0f);
output(x,y) = make_float4((n/-l), 1.0f);
}
}
}
@@ -131,22 +131,22 @@ __global__ void smooth_normals_kernel(ftl::cuda::TextureObject<float4> norms,
//if (s > 0.0f) {
const float4 n = norms.tex2D((int)x+u,(int)y+v);
//if (n.w > 0.0f) {
if (n.w > 0.0f) {
nsum += make_float3(n) * s;
contrib += s;
//}
}
//}
}
}
// Compute dot product of normal with camera to obtain measure of how
// well this point faces the source camera, a measure of confidence
float3 ray = pose * camera.screenToCam(x, y, 1.0f);
float3 ray = camera.screenToCam(x, y, 1.0f);
ray = ray / length(ray);
nsum /= contrib;
nsum /= length(nsum);
output(x,y) = (contrib > 0.0f) ? make_float4(nsum, 1.0f) : make_float4(0.0f); //dot(nsum, ray)
output(x,y) = (contrib > 0.0f) ? make_float4(pose*nsum, 1.0f) : make_float4(0.0f);
}
void ftl::cuda::normals(ftl::cuda::TextureObject<float4> &output,
@@ -163,9 +163,10 @@ void ftl::cuda::normals(ftl::cuda::TextureObject<float4> &output,
cudaSafeCall( cudaGetLastError() );
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 9: smooth_normals_kernel<9><<<gridSize, blockSize, 0, stream>>>(temp, output, input, camera, pose, smoothing); break;
case 7: smooth_normals_kernel<7><<<gridSize, blockSize, 0, stream>>>(temp, output, input, camera, pose, smoothing); break;
case 5: smooth_normals_kernel<5><<<gridSize, blockSize, 0, stream>>>(temp, output, input, camera, pose, smoothing); break;
case 3: smooth_normals_kernel<3><<<gridSize, blockSize, 0, stream>>>(temp, output, input, camera, pose, smoothing); break;
}
cudaSafeCall( cudaGetLastError() );
@@ -189,9 +190,9 @@ void ftl::cuda::normals(ftl::cuda::TextureObject<float4> &output,
cudaSafeCall( cudaGetLastError() );
switch (radius) {
case 7: smooth_normals_kernel<7><<<gridSize, blockSize, 0, stream>>>(temp, output, input, camera, pose_inv, smoothing);
case 5: smooth_normals_kernel<5><<<gridSize, blockSize, 0, stream>>>(temp, output, input, camera, pose_inv, smoothing);
case 3: smooth_normals_kernel<3><<<gridSize, blockSize, 0, stream>>>(temp, output, input, camera, pose_inv, smoothing);
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);
}
cudaSafeCall( cudaGetLastError() );
Loading