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

Dont use MINF in normals

parent 8f686002
No related branches found
No related tags found
Loading
This commit is part of merge request !115. Comments created here will be created in the context of that merge request.
...@@ -10,7 +10,7 @@ __global__ void computeNormals_kernel(ftl::cuda::TextureObject<float4> output, ...@@ -10,7 +10,7 @@ __global__ void computeNormals_kernel(ftl::cuda::TextureObject<float4> output,
if(x >= input.width() || y >= input.height()) return; if(x >= input.width() || y >= input.height()) return;
output(x,y) = make_float4(MINF, MINF, MINF, MINF); output(x,y) = make_float4(0, 0, 0, 0);
if(x > 0 && x < input.width()-1 && y > 0 && y < input.height()-1) { if(x > 0 && x < input.width()-1 && y > 0 && y < input.height()-1) {
const float3 CC = make_float3(input.tex2D((int)x+0, (int)y+0)); //[(y+0)*width+(x+0)]; const float3 CC = make_float3(input.tex2D((int)x+0, (int)y+0)); //[(y+0)*width+(x+0)];
...@@ -19,14 +19,14 @@ __global__ void computeNormals_kernel(ftl::cuda::TextureObject<float4> output, ...@@ -19,14 +19,14 @@ __global__ void computeNormals_kernel(ftl::cuda::TextureObject<float4> output,
const float3 MC = make_float3(input.tex2D((int)x+0, (int)y-1)); //[(y-1)*width+(x+0)]; const float3 MC = make_float3(input.tex2D((int)x+0, (int)y-1)); //[(y-1)*width+(x+0)];
const float3 CM = make_float3(input.tex2D((int)x-1, (int)y+0)); //[(y+0)*width+(x-1)]; const float3 CM = make_float3(input.tex2D((int)x-1, (int)y+0)); //[(y+0)*width+(x-1)];
if(CC.x != MINF && PC.x != MINF && CP.x != MINF && MC.x != MINF && CM.x != MINF) { //if(CC.x != MINF && PC.x != MINF && CP.x != MINF && MC.x != MINF && CM.x != MINF) {
const float3 n = cross(PC-MC, CP-CM); const float3 n = cross(PC-MC, CP-CM);
const float l = length(n); const float l = length(n);
if(l > 0.0f) { if(l > 0.0f) {
output(x,y) = make_float4(n/-l, 1.0f); output(x,y) = make_float4(n/-l, 1.0f);
} }
} //}
} }
} }
...@@ -58,8 +58,9 @@ __global__ void vis_normals_kernel(ftl::cuda::TextureObject<float4> norm, ...@@ -58,8 +58,9 @@ __global__ void vis_normals_kernel(ftl::cuda::TextureObject<float4> norm,
float3 ray = make_float3(0.0f, 0.0f, 1.0f); //pose * camera.screenToCam(x,y,1.0f); float3 ray = make_float3(0.0f, 0.0f, 1.0f); //pose * camera.screenToCam(x,y,1.0f);
ray = ray / length(ray); ray = ray / length(ray);
float3 n = make_float3(norm.tex2D((int)x,(int)y)); float3 n = make_float3(norm.tex2D((int)x,(int)y));
if (n.x == MINF) return; float l = length(n);
n /= length(n); if (l == 0) return;
n /= l;
output(x,y) = fabs(dot(ray, n))*7.0f; output(x,y) = fabs(dot(ray, n))*7.0f;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment