@@ -266,11 +266,13 @@ renderCUDA(
266266 int W, int H,
267267 const float2 * __restrict__ points_xy_image,
268268 const float * __restrict__ features,
269+ const float * __restrict__ depths,
269270 const float4 * __restrict__ conic_opacity,
270271 float * __restrict__ final_T,
271272 uint32_t * __restrict__ n_contrib,
272273 const float * __restrict__ bg_color,
273- float * __restrict__ out_color)
274+ float * __restrict__ out_color,
275+ float * __restrict__ out_depth)
274276{
275277 // Identify current tile and associated min/max pixel range.
276278 auto block = cg::this_thread_block ();
@@ -301,6 +303,7 @@ renderCUDA(
301303 uint32_t contributor = 0 ;
302304 uint32_t last_contributor = 0 ;
303305 float C[CHANNELS] = { 0 };
306+ float D = { 0 };
304307
305308 // Iterate over batches until all done or range is complete
306309 for (int i = 0 ; i < rounds; i++, toDo -= BLOCK_SIZE)
@@ -353,6 +356,7 @@ renderCUDA(
353356 // Eq. (3) from 3D Gaussian splatting paper.
354357 for (int ch = 0 ; ch < CHANNELS; ch++)
355358 C[ch] += features[collected_id[j] * CHANNELS + ch] * alpha * T;
359+ D += depths[collected_id[j]] * alpha * T;
356360
357361 T = test_T;
358362
@@ -370,6 +374,7 @@ renderCUDA(
370374 n_contrib[pix_id] = last_contributor;
371375 for (int ch = 0 ; ch < CHANNELS; ch++)
372376 out_color[ch * H * W + pix_id] = C[ch] + T * bg_color[ch];
377+ out_depth[pix_id] = D;
373378 }
374379}
375380
@@ -380,23 +385,27 @@ void FORWARD::render(
380385 int W, int H,
381386 const float2 * means2D,
382387 const float * colors,
388+ const float * depths,
383389 const float4 * conic_opacity,
384390 float * final_T,
385391 uint32_t * n_contrib,
386392 const float * bg_color,
387- float * out_color)
393+ float * out_color,
394+ float * out_depth)
388395{
389396 renderCUDA<NUM_CHANNELS> << <grid, block >> > (
390397 ranges,
391398 point_list,
392399 W, H,
393400 means2D,
394401 colors,
402+ depths,
395403 conic_opacity,
396404 final_T,
397405 n_contrib,
398406 bg_color,
399- out_color);
407+ out_color,
408+ out_depth);
400409}
401410
402411void FORWARD::preprocess (int P, int D, int M,
0 commit comments