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

render diamonds

parent 85443e8d
No related branches found
No related tags found
1 merge request!151Implements #216 triangle renderer
......@@ -101,21 +101,21 @@ __device__ static
const int x = blockIdx.x*blockDim.x + threadIdx.x;
const int y = blockIdx.y*blockDim.y + threadIdx.y;
if (x < 0 || x >= depth_in.width()-1 || y < 0 || y >= depth_in.height()-1) return;
if (x < 1 || x >= depth_in.width()-1 || y < 1 || y >= depth_in.height()-1) return;
float d[3];
d[0] = depth_in.tex2D(x+A,y+B);
d[1] = depth_in.tex2D(x+(1-A),y+B);
d[2] = depth_in.tex2D(x+A,y+(1-B));
d[0] = depth_in.tex2D(x,y);
d[1] = depth_in.tex2D(x+A,y);
d[2] = depth_in.tex2D(x,y+B);
// Is this triangle valid
if (fabs(d[0] - d[1]) > 0.04f || fabs(d[0] - d[2]) > 0.04f || fabs(d[1] - d[2]) > 0.04f) return;
if (fabs(d[0] - d[1]) > 0.04f || fabs(d[0] - d[2]) > 0.04f) return;
if (d[0] < params.camera.minDepth || d[0] > params.camera.maxDepth) return;
short2 v[3];
v[0] = screen.tex2D(x+A,y+B);
v[1] = screen.tex2D(x+(1-A),y+B);
v[2] = screen.tex2D(x+A,y+(1-B));
v[0] = screen.tex2D(x,y);
v[1] = screen.tex2D(x+A,y);
v[2] = screen.tex2D(x,y+B);
const int minX = min(v[0].x, min(v[1].x, v[2].x));
const int minY = min(v[0].y, min(v[1].y, v[2].y));
......@@ -199,9 +199,9 @@ void ftl::cuda::triangle_render1(TextureObject<float> &depth_in, TextureObject<i
const dim3 gridSize((depth_in.width() + T_PER_BLOCK - 1)/T_PER_BLOCK, (depth_in.height() + T_PER_BLOCK - 1)/T_PER_BLOCK);
const dim3 blockSize(T_PER_BLOCK, T_PER_BLOCK);
triangle_render_1_kernel<0,0><<<gridSize, blockSize, 0, stream>>>(depth_in, depth_out, screen, params);
triangle_render_1_kernel<0,1><<<gridSize, blockSize, 0, stream>>>(depth_in, depth_out, screen, params);
triangle_render_1_kernel<1,0><<<gridSize, blockSize, 0, stream>>>(depth_in, depth_out, screen, params);
triangle_render_1_kernel<1,1><<<gridSize, blockSize, 0, stream>>>(depth_in, depth_out, screen, params);
triangle_render_1_kernel<1,-1><<<gridSize, blockSize, 0, stream>>>(depth_in, depth_out, screen, params);
triangle_render_1_kernel<-1,1><<<gridSize, blockSize, 0, stream>>>(depth_in, depth_out, screen, params);
triangle_render_1_kernel<-1,-1><<<gridSize, blockSize, 0, stream>>>(depth_in, depth_out, screen, params);
cudaSafeCall( cudaGetLastError() );
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment