MCPcopy Create free account
hub / github.com/XPandora/PhysGaussian / convert_SH

Function convert_SH

utils/render_utils.py:113–130  ·  view source on GitHub ↗
(
    shs_view,
    viewpoint_camera,
    pc: GaussianModel,
    position: torch.tensor,
    rotation: torch.tensor = None,
)

Source from the content-addressed store, hash-verified

111
112
113def convert_SH(
114 shs_view,
115 viewpoint_camera,
116 pc: GaussianModel,
117 position: torch.tensor,
118 rotation: torch.tensor = None,
119):
120 shs_view = shs_view.transpose(1, 2).view(-1, 3, (pc.max_sh_degree + 1) ** 2)
121 dir_pp = position - viewpoint_camera.camera_center.repeat(shs_view.shape[0], 1)
122 if rotation is not None:
123 n = rotation.shape[0]
124 dir_pp[:n] = torch.matmul(rotation, dir_pp[:n].unsqueeze(2)).squeeze(2)
125
126 dir_pp_normalized = dir_pp / dir_pp.norm(dim=1, keepdim=True)
127 sh2rgb = eval_sh(pc.active_sh_degree, shs_view, dir_pp_normalized)
128 colors_precomp = torch.clamp_min(sh2rgb + 0.5, 0.0)
129
130 return colors_precomp

Callers 1

gs_simulation.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected