Commit af946bea by Bernhard Kerbl

Support for fill color

parent cc408a20
......@@ -264,6 +264,7 @@ __global__ void renderCUDA(
float* __restrict__ final_T,
uint32_t* __restrict__ n_contrib,
const float* __restrict__ bg_color,
const float* __restrict__ fill_bg_color,
float* __restrict__ out_color)
{
// Identify current tile and associated min/max pixel range.
......@@ -362,6 +363,11 @@ __global__ void renderCUDA(
{
final_T[pix_id] = T;
n_contrib[pix_id] = last_contributor;
if(last_contributor == 0)
for (int ch = 0; ch < CHANNELS; ch++)
out_color[ch * H * W + pix_id] = fill_bg_color[ch];
else
for (int ch = 0; ch < CHANNELS; ch++)
out_color[ch * H * W + pix_id] = C[ch] + T * bg_color[ch];
}
......@@ -378,6 +384,7 @@ void FORWARD::render(
float* final_T,
uint32_t* n_contrib,
const float* bg_color,
const float* fill_bg_color,
float* out_color)
{
renderCUDA<NUM_CHANNELS> << <grid, block >> > (
......@@ -390,6 +397,7 @@ void FORWARD::render(
final_T,
n_contrib,
bg_color,
fill_bg_color,
out_color);
}
......
......@@ -48,6 +48,7 @@ namespace FORWARD
float* final_T,
uint32_t* n_contrib,
const float* bg_color,
const float* fill_bg_color,
float* out_color);
}
......
......@@ -38,7 +38,8 @@ namespace CudaRasterizer
const float tan_fovx, float tan_fovy,
const bool prefiltered,
float* out_color,
int* radii = nullptr);
int* radii = nullptr,
const float* fill_background = nullptr);
static void backward(
const int P, int D, int M, int R,
......
......@@ -205,7 +205,8 @@ int CudaRasterizer::Rasterizer::forward(
const float tan_fovx, float tan_fovy,
const bool prefiltered,
float* out_color,
int* radii)
int* radii,
const float* fill_background)
{
const float focal_y = height / (2.0f * tan_fovy);
const float focal_x = width / (2.0f * tan_fovx);
......@@ -215,9 +216,10 @@ int CudaRasterizer::Rasterizer::forward(
GeometryState geomState = GeometryState::fromChunk(chunkptr, P);
if (radii == nullptr)
{
radii = geomState.internal_radii;
}
if (fill_background == nullptr)
fill_background = background;
dim3 tile_grid((width + BLOCK_X - 1) / BLOCK_X, (height + BLOCK_Y - 1) / BLOCK_Y, 1);
dim3 block(BLOCK_X, BLOCK_Y, 1);
......@@ -318,6 +320,7 @@ int CudaRasterizer::Rasterizer::forward(
imgState.accum_alpha,
imgState.n_contrib,
background,
fill_background,
out_color);
return num_rendered;
......@@ -360,9 +363,7 @@ void CudaRasterizer::Rasterizer::backward(
ImageState imgState = ImageState::fromChunk(img_buffer, width * height);
if (radii == nullptr)
{
radii = geomState.internal_radii;
}
const float focal_y = height / (2.0f * tan_fovy);
const float focal_x = width / (2.0f * tan_fovx);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment