Skip to content

Commit

Permalink
Render accumulation
Browse files Browse the repository at this point in the history
  • Loading branch information
jkulhanek committed Feb 7, 2024
1 parent 59f5f77 commit 3d4d45d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions diff_gaussian_rasterization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,17 @@ def forward(
ctx.raster_settings = raster_settings
ctx.num_rendered = num_rendered
ctx.save_for_backward(colors_precomp, means3D, scales, rotations, cov3Ds_precomp, radii, sh, geomBuffer, binningBuffer, imgBuffer)
return color, radii

accumulation = None
if raster_settings.return_accumulation:
alignment = 128
offset = (alignment - imgBuffer.data_ptr()) % alignment
total_size = raster_settings.image_height * raster_settings.image_width * 4
accumulation = imgBuffer[offset: offset + total_size].view(torch.float32).clone().view((raster_settings.image_height, raster_settings.image_width))
return color, radii, accumulation

@staticmethod
def backward(ctx, grad_out_color, _):
def backward(ctx, grad_out_color, _1, _2):

# Restore necessary values from context
num_rendered = ctx.num_rendered
Expand Down Expand Up @@ -167,6 +174,7 @@ class GaussianRasterizationSettings(NamedTuple):
campos : torch.Tensor
prefiltered : bool
debug : bool
return_accumulation : bool

class GaussianRasterizer(nn.Module):
def __init__(self, raster_settings):
Expand Down

0 comments on commit 3d4d45d

Please sign in to comment.