@@ -285,7 +285,8 @@ renderCUDA(
285
285
const float * __restrict__ bg_color,
286
286
float * __restrict__ out_color,
287
287
const float * __restrict__ depths,
288
- float * __restrict__ invdepth)
288
+ float * __restrict__ invdepth,
289
+ float * __restrict__ out_depth)
289
290
{
290
291
// Identify current tile and associated min/max pixel range.
291
292
auto block = cg::this_thread_block ();
@@ -310,12 +311,14 @@ renderCUDA(
310
311
__shared__ int collected_id[BLOCK_SIZE];
311
312
__shared__ float2 collected_xy[BLOCK_SIZE];
312
313
__shared__ float4 collected_conic_opacity[BLOCK_SIZE];
314
+ __shared__ float collected_depth[BLOCK_SIZE];
313
315
314
316
// Initialize helper variables
315
317
float T = 1 .0f ;
316
318
uint32_t contributor = 0 ;
317
319
uint32_t last_contributor = 0 ;
318
320
float C[CHANNELS] = { 0 };
321
+ float D = 65503 .0f ; // Median Depth. TODO: This is a hack setting max_depth to 65503.0
319
322
320
323
float expected_invdepth = 0 .0f ;
321
324
@@ -335,6 +338,7 @@ renderCUDA(
335
338
collected_id[block.thread_rank ()] = coll_id;
336
339
collected_xy[block.thread_rank ()] = points_xy_image[coll_id];
337
340
collected_conic_opacity[block.thread_rank ()] = conic_opacity[coll_id];
341
+ collected_depth[block.thread_rank ()] = depths[coll_id];
338
342
}
339
343
block.sync ();
340
344
@@ -371,6 +375,10 @@ renderCUDA(
371
375
for (int ch = 0 ; ch < CHANNELS; ch++)
372
376
C[ch] += features[collected_id[j] * CHANNELS + ch] * alpha * T;
373
377
378
+ // Median depth:
379
+ if (T > 0 .5f && test_T < 0.5 )
380
+ D = collected_depth[j];
381
+
374
382
if (invdepth)
375
383
expected_invdepth += (1 / depths[collected_id[j]]) * alpha * T;
376
384
@@ -390,6 +398,7 @@ renderCUDA(
390
398
n_contrib[pix_id] = last_contributor;
391
399
for (int ch = 0 ; ch < CHANNELS; ch++)
392
400
out_color[ch * H * W + pix_id] = C[ch] + T * bg_color[ch];
401
+ out_depth[pix_id] = D;
393
402
394
403
if (invdepth)
395
404
invdepth[pix_id] = expected_invdepth;// 1. / (expected_depth + T * 1e3);
@@ -409,7 +418,8 @@ void FORWARD::render(
409
418
const float * bg_color,
410
419
float * out_color,
411
420
float * depths,
412
- float * depth)
421
+ float * invdepth,
422
+ float * out_depth)
413
423
{
414
424
renderCUDA<NUM_CHANNELS> << <grid, block >> > (
415
425
ranges,
@@ -423,7 +433,8 @@ void FORWARD::render(
423
433
bg_color,
424
434
out_color,
425
435
depths,
426
- depth);
436
+ invdepth,
437
+ out_depth);
427
438
}
428
439
429
440
void FORWARD::preprocess (int P, int D, int M,
0 commit comments