diff --git a/components/renderers/cpp/src/normals.cu b/components/renderers/cpp/src/normals.cu index 2b41c69527e8b5438589b03102f8b95d3512a546..cf64f4036fa02ab7b4e5ffa10c5e3b65a79732b7 100644 --- a/components/renderers/cpp/src/normals.cu +++ b/components/renderers/cpp/src/normals.cu @@ -10,7 +10,7 @@ __global__ void computeNormals_kernel(ftl::cuda::TextureObject<float4> output, 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) { 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, 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)]; - 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 float l = length(n); if(l > 0.0f) { output(x,y) = make_float4(n/-l, 1.0f); } - } + //} } } @@ -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); ray = ray / length(ray); float3 n = make_float3(norm.tex2D((int)x,(int)y)); - if (n.x == MINF) return; - n /= length(n); + float l = length(n); + if (l == 0) return; + n /= l; output(x,y) = fabs(dot(ray, n))*7.0f; }