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

Some tweaks

parent 04cdb62a
No related branches found
No related tags found
1 merge request!151Implements #216 triangle renderer
......@@ -31,7 +31,7 @@ __device__ inline float length2(int dx, int dy) { return dx*dx + dy*dy; }
// Is this triangle valid
if (fabs(d[0] - d[1]) > 0.04f || fabs(d[0] - d[2]) > 0.04f) return;
if (d[0] < params.camera.minDepth || d[1] < params.camera.minDepth || d[2] < params.camera.minDepth) return;
if (d[0] < params.camera.minDepth || d[0] > params.camera.maxDepth) return;
short2 s[3];
s[0] = screen.tex2D(x+A,y+B);
......@@ -46,11 +46,13 @@ __device__ inline float length2(int dx, int dy) { return dx*dx + dy*dy; }
s[2].x -= s[0].x;
s[2].y = (B) ? s[0].y - s[2].y : s[2].y - s[0].y;
s[1].x = min(s[1].x,10);
s[2].y = min(s[2].y,10);
//if (s[1].y < 0 || s[2].x < 0) return;
for (int sx=0; sx <= s[1].x; ++sx) {
for (int sy=0; sy <= min(s[1].x - sx, s[2].y); ++sy) {
s[1].x = min(s[1].x,20);
s[2].y = min(s[2].y,20);
for (int sx=0; sx < s[1].x+1; ++sx) {
for (int sy=0; sy < min(s[1].x - sx, s[2].y)+1; ++sy) {
//if (sx > s[2].y-sy) continue;
if (dx*sx+s[0].x >= params.camera.width || dy*sy+s[0].y >= params.camera.height) continue;
......@@ -58,7 +60,7 @@ __device__ inline float length2(int dx, int dy) { return dx*dx + dy*dy; }
float dist2 = length2(s[1].x-sx, s[1].y-sy);
float dist3 = length2(s[2].x-sx, s[2].y-sy);
float new_depth = (d[0]*dist1 + d[1]*dist2 + d[2] * dist3) / (dist1+dist2+dist3);
float new_depth = (dist1+dist2+dist3 == 0.0f) ? d[0] : (d[0]*dist1 + d[1]*dist2 + d[2] * dist3) / (dist1+dist2+dist3);
//if (new_depth < params.camera.minDepth || new_depth > params.camera.maxDepth) continue;
atomicMin(&depth_out(dx*sx+s[0].x,dy*sy+s[0].y), int(new_depth*1000.0f));
......
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