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

Correct comp problems

parent e038d911
No related branches found
No related tags found
1 merge request!115Implements #141 normals
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
namespace ftl { namespace ftl {
namespace cuda { namespace cuda {
void ftl::cuda::normals(ftl::cuda::TextureObject<float4> &output, void normals(ftl::cuda::TextureObject<float4> &output,
ftl::cuda::TextureObject<float4> &input, cudaStream_t stream); ftl::cuda::TextureObject<float4> &input, cudaStream_t stream);
} }
......
#include <ftl/cuda/normals.hpp> #include <ftl/cuda/normals.hpp>
#define T_PER_BLOCK 16 #define T_PER_BLOCK 16
#define MINF __int_as_float(0xff800000)
__global__ void computeNormals_kernel(ftl::cuda::TextureObject<float4> output, __global__ void computeNormals_kernel(ftl::cuda::TextureObject<float4> output,
ftl::cuda::TextureObject<float4> input) { ftl::cuda::TextureObject<float4> input) {
...@@ -12,11 +13,11 @@ __global__ void computeNormals_kernel(ftl::cuda::TextureObject<float4> output, ...@@ -12,11 +13,11 @@ __global__ void computeNormals_kernel(ftl::cuda::TextureObject<float4> output,
output(x,y) = make_float4(MINF, MINF, MINF, MINF); output(x,y) = make_float4(MINF, MINF, MINF, MINF);
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(x+0, 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)];
const float3 PC = make_float3(input.tex2D(x+0, y+1)); //[(y+1)*width+(x+0)]; const float3 PC = make_float3(input.tex2D((int)x+0, (int)y+1)); //[(y+1)*width+(x+0)];
const float3 CP = make_float3(input.tex2D(x+1, y+0)); //[(y+0)*width+(x+1)]; const float3 CP = make_float3(input.tex2D((int)x+1, (int)y+0)); //[(y+0)*width+(x+1)];
const float3 MC = make_float3(input.tex2D(x+0, 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(x-1, 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);
......
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