(gaussians: dict, bg_color: torch.Tensor, timestamps: torch.Tensor = None, scaling_modifier=1.0,
opt: Options=None, anchor_time: torch.Tensor=None,
training=True, override_opacity=False,
)
| 62 | tanfovy = math.tan(math.pi / 4.0) |
| 63 | |
| 64 | def render(gaussians: dict, bg_color: torch.Tensor, timestamps: torch.Tensor = None, scaling_modifier=1.0, |
| 65 | opt: Options=None, anchor_time: torch.Tensor=None, |
| 66 | training=True, override_opacity=False, |
| 67 | ): |
| 68 | |
| 69 | # random background color augmentation |
| 70 | if training: |
| 71 | bg_color = torch.rand(3).cuda() |
| 72 | else: |
| 73 | # bg_color = torch.tensor([1.0, 1.0, 1.0]).cuda() |
| 74 | bg_color = torch.tensor([0.5, 0.5, 0.5]).cuda() |
| 75 | |
| 76 | # bg_color = torch.tensor([0.5, 0.5, 0.5]).cuda() |
| 77 | L = 0 |
| 78 | LP = opt.forder |
| 79 | |
| 80 | batch_size, gaussian_num = gaussians['xyz'].shape[0], gaussians['xyz'].shape[1] |
| 81 | |
| 82 | screenspace_points = torch.zeros_like(gaussians['xyz'][:, :, 0, :], dtype=gaussians['xyz'].dtype, requires_grad=True, device=gaussians['xyz'].device) |
| 83 | screenspace_points.retain_grad() |
| 84 | |
| 85 | view_matrix = world_view_transform.float() # View matrix |
| 86 | view_proj_matrix = full_proj_transform.float() # Projection matrix |
| 87 | campos = camera_center.float() # Camera position |
| 88 | |
| 89 | if len(opt.down_resolution) > 0: |
| 90 | render_height, render_width = opt.down_resolution |
| 91 | else: |
| 92 | render_height, render_width = opt.image_height, opt.image_width |
| 93 | raster_settings = GaussianRasterizationSettingsOrth( |
| 94 | image_height=render_height, |
| 95 | image_width=render_width, |
| 96 | tanfovx=tanfovx, |
| 97 | tanfovy=tanfovy, |
| 98 | bg=bg_color if bg_color is not None else bg_color, |
| 99 | scale_modifier=scaling_modifier, |
| 100 | viewmatrix=view_matrix.cuda(), |
| 101 | projmatrix=view_proj_matrix.cuda(), |
| 102 | sh_degree=0, |
| 103 | campos=campos.cuda(), |
| 104 | prefiltered=False, |
| 105 | debug=False, |
| 106 | ) |
| 107 | |
| 108 | rasterizer = GaussianRasterizerOrth(raster_settings=raster_settings) |
| 109 | render_images = [] |
| 110 | render_depths = [] |
| 111 | render_alphas = [] |
| 112 | |
| 113 | dummy_time = torch.zeros(1, device=gaussians['xyz'].device) |
| 114 | output_frames = opt.output_frames |
| 115 | N = gaussians['xyz'].shape[1] |
| 116 | if timestamps is None: |
| 117 | output_frames = 1 |
| 118 | timestamps = dummy_time.repeat(batch_size, output_frames) |
| 119 | if anchor_time is None: |
| 120 | anchor_time = torch.zeros((N, 1), device=gaussians['xyz'].device) |
| 121 | else: |
nothing calls this directly
no outgoing calls
no test coverage detected