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

Experiments with different splat weightings

parent c305aeef
No related branches found
No related tags found
1 merge request!123Implements #189 using density to estimate radius
Pipeline #15085 passed
...@@ -49,8 +49,7 @@ __device__ inline bool intersectDisk(const float3 &n, const float3 &p0, float ra ...@@ -49,8 +49,7 @@ __device__ inline bool intersectDisk(const float3 &n, const float3 &p0, float ra
* @param l Normalised ray direction in camera space * @param l Normalised ray direction in camera space
* @return Radius from centre of disk where intersection occurred. * @return Radius from centre of disk where intersection occurred.
*/ */
__device__ inline float intersectDistance(const float3 &n, const float3 &p0, const float3 &l0, const float3 &l) { __device__ inline float intersectDistance(const float3 &n, const float3 &p0, const float3 &l0, const float3 &l, float &t) {
float t = 0;
if (intersectPlane(n, p0, l0, l, t)) { if (intersectPlane(n, p0, l0, l, t)) {
const float3 p = l0 + l * t; const float3 p = l0 + l * t;
const float3 v = p - p0; const float3 v = p - p0;
......
...@@ -406,7 +406,7 @@ bool Splatter::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out, cuda ...@@ -406,7 +406,7 @@ bool Splatter::render(ftl::rgbd::VirtualSource *src, ftl::rgbd::Frame &out, cuda
// Convert normal to single float value // Convert normal to single float value
temp_.create<GpuMat>(Channel::Colour, Format<uchar4>(camera.width, camera.height)); temp_.create<GpuMat>(Channel::Colour, Format<uchar4>(camera.width, camera.height));
ftl::cuda::normal_visualise(out.getTexture<float4>(Channel::Normals), temp_.createTexture<uchar4>(Channel::Colour), ftl::cuda::normal_visualise(out.getTexture<float4>(Channel::Normals), temp_.createTexture<uchar4>(Channel::Colour),
make_float3(-0.3f, 0.2f, 1.0f), make_float3(0.3f, 0.2f, 1.0f),
light_diffuse_, light_diffuse_,
light_ambient_, stream); light_ambient_, stream);
......
...@@ -176,6 +176,7 @@ __device__ inline float make(float v) { ...@@ -176,6 +176,7 @@ __device__ inline float make(float v) {
//float depth = 0.0f; //float depth = 0.0f;
//float contrib = 0.0f; //float contrib = 0.0f;
float depth = 1000.0f; float depth = 1000.0f;
float pdepth = 1000.0f;
struct Result { struct Result {
float weight; float weight;
...@@ -198,22 +199,23 @@ __device__ inline float make(float v) { ...@@ -198,22 +199,23 @@ __device__ inline float make(float v) {
if (d < params.camera.minDepth || d > params.camera.maxDepth) continue; if (d < params.camera.minDepth || d > params.camera.maxDepth) continue;
const float3 camPos = params.camera.screenToCam((int)(x+u),(int)(y+v),d); const float3 camPos = params.camera.screenToCam((int)(x)+u,(int)(y)+v,d);
const float3 camPos2 = params.camera.screenToCam((int)(x),(int)(y),d); const float3 camPos2 = params.camera.screenToCam((int)(x),(int)(y),d);
const float3 worldPos = params.m_viewMatrixInverse * camPos; const float3 worldPos = params.m_viewMatrixInverse * camPos;
// Assumed to be normalised // 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"); //if (length(make_float3(n)) == 0.0f) printf("BAD NORMAL\n");
// Does the ray intersect plane of splat? // Does the ray intersect plane of splat?
float t = 1000.0f; float t = 1000.0f;
if (ftl::cuda::intersectPlane(make_float3(n), worldPos, origin, ray, t)) { //} && fabs(t-camPos.z) < 0.01f) { const float r = ftl::cuda::intersectDistance(make_float3(n), worldPos, origin, ray, t);
if (r != PINF) { //} && fabs(t-camPos.z) < 0.01f) {
// Adjust from normalised ray back to original meters units // Adjust from normalised ray back to original meters units
t *= scale; t *= scale;
const float3 camPos3 = params.camera.screenToCam((int)(x),(int)(y),t); float weight = ftl::cuda::weighting(r, 2.0f/params.camera.fx); // (1.0f/params.camera.fx) / (t/params.camera.fx)
float weight = ftl::cuda::spatialWeighting(camPos, camPos3, 2.0f*(camPos3.z/params.camera.fx));
/* Buehler C. et al. 2001. Unstructured Lumigraph Rendering. */ /* Buehler C. et al. 2001. Unstructured Lumigraph Rendering. */
/* Orts-Escolano S. et al. 2016. Holoportation: Virtual 3D teleportation in real-time. */ /* Orts-Escolano S. et al. 2016. Holoportation: Virtual 3D teleportation in real-time. */
...@@ -226,12 +228,17 @@ __device__ inline float make(float v) { ...@@ -226,12 +228,17 @@ __device__ inline float make(float v) {
if (weight <= 0.0f) continue; if (weight <= 0.0f) continue;
depth = min(depth, t); //depth = min(depth, t);
if (t < depth) {
pdepth = depth;
depth = t;
}
results[i/WARP_SIZE] = {weight, t, in.tex2D((int)x+u, (int)y+v)}; results[i/WARP_SIZE] = {weight, t, in.tex2D((int)x+u, (int)y+v)};
} }
} }
depth = warpMin(depth); depth = warpMin(depth);
pdepth = warpMin(pdepth);
float adepth = 0.0f; float adepth = 0.0f;
float contrib = 0.0f; float contrib = 0.0f;
...@@ -378,7 +385,7 @@ __global__ void dibr_attribute_contrib_kernel( ...@@ -378,7 +385,7 @@ __global__ void dibr_attribute_contrib_kernel(
const float d = (float)depth_in.tex2D((int)screenPos.x, (int)screenPos.y) / 1000.0f; const float d = (float)depth_in.tex2D((int)screenPos.x, (int)screenPos.y) / 1000.0f;
const A input = generateInput(in.tex2D(x, y), params, worldPos); const A input = generateInput(in.tex2D(x, y), params, worldPos);
const float weight = ftl::cuda::weighting(fabs(camPos.z - d), 0.01f); const float weight = ftl::cuda::weighting(fabs(camPos.z - d), 0.002f);
const B weighted = make<B>(input) * weight; //weightInput(input, weight); const B weighted = make<B>(input) * weight; //weightInput(input, weight);
if (weight > 0.0f) { if (weight > 0.0f) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment