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

Change normal viz

parent 04b04fe5
No related branches found
No related tags found
1 merge request!358Updates to SDK and alternative fusion
Pipeline #33701 passed
......@@ -146,7 +146,7 @@ __device__ inline float biasedLength(const float3 &Xi, const float3 &X) {
// TODO: Angle from cam (dot of normal and ray)
//const float w_lateral = ftl::cuda::weighting(sqrt(Xi.x*X.x + Xi.y*X.y), float(SEARCH_RADIUS)*camera_origin.fx/Xi.z);
const float w = (length(Ni) > 0.0f)
?w_space * w_high_int * w_mean_int // min(w_space, min(w_high_int, w_mean_int))
? min(w_space, min(w_high_int, w_mean_int)) //w_space * w_high_int * w_mean_int //
: 0.0f;
// Mark as a symmetry contribution
......
......@@ -417,6 +417,8 @@ void CUDARender::_mesh(ftl::rgbd::Frame &out, const Eigen::Matrix4d &t, cudaStre
);*/
}
//out.createTexture<half4>(_getNormalsChannel());
ftl::cuda::transform_normals(
out.createTexture<half4>(_getNormalsChannel()),
poseInverse_.getFloat3x3(),
......
......@@ -409,7 +409,7 @@ void ftl::cuda::normals_dot(ftl::cuda::TextureObject<float> &output,
//==============================================================================
__global__ void vis_normals_kernel(ftl::cuda::TextureObject<half4> norm,
/*__global__ void vis_normals_kernel(ftl::cuda::TextureObject<half4> norm,
ftl::cuda::TextureObject<uchar4> output,
float3 direction, uchar4 diffuse, uchar4 ambient) {
const unsigned int x = blockIdx.x*blockDim.x + threadIdx.x;
......@@ -433,6 +433,42 @@ __global__ void vis_normals_kernel(ftl::cuda::TextureObject<half4> norm,
min(255.0f, diffuse.z*d + ambient.z), ambient.w);
}
}
}*/
__global__ void vis_normals_kernel(ftl::cuda::TextureObject<half4> norm,
ftl::cuda::TextureObject<uchar4> output,
float3 direction, uchar4 diffuse, uchar4 ambient
) {
const unsigned int x = blockIdx.x*blockDim.x + threadIdx.x;
const unsigned int y = blockIdx.y*blockDim.y + threadIdx.y;
if(x < norm.width() && y < norm.height()) {
output(x,y) = make_uchar4(ambient.x,ambient.y,ambient.z,0);
//float3 ray = direction;
//ray = ray / length(ray);
float3 n = make_float3(norm.tex2D((int)x,(int)y));
float l = length(n);
if (l != 0) {
n /= l;
const float b = (n.z + 1.0f) * 0.5f * 255.0f;
const float g = (n.y + 1.0f) * 0.5f * 255.0f;
const float r = (n.x + 1.0f) * 0.5f * 255.0f;
//const float d = max(dot(ray, n), 0.0f);
/*output(x,y) = make_uchar4(
min(255.0f, diffuse.x*d + ambient.x),
min(255.0f, diffuse.y*d + ambient.y),
min(255.0f, diffuse.z*d + ambient.z), ambient.w);*/
output(x,y) = make_uchar4(
min(255.0f, b + ambient.x),
min(255.0f, g + ambient.y),
min(255.0f, r + ambient.z), ambient.w);
}
}
}
void ftl::cuda::normal_visualise(ftl::cuda::TextureObject<half4> &norm,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment