From 5f4cb368ab4ae49037dc53653c6cc06312685f8d Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Wed, 2 Oct 2019 11:00:20 +0300 Subject: [PATCH] Dont use MINF in normals --- components/renderers/cpp/src/normals.cu | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/components/renderers/cpp/src/normals.cu b/components/renderers/cpp/src/normals.cu index 2b41c6952..cf64f4036 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; } -- GitLab