Spaces:
Running
on
Zero
Running
on
Zero
Update trellis/utils/render_utils.py
Browse files
trellis/utils/render_utils.py
CHANGED
@@ -31,7 +31,7 @@ def yaw_pitch_r_fov_to_extrinsics_intrinsics(yaws, pitchs, rs, fovs):
|
|
31 |
torch.sin(pitch),
|
32 |
]).cuda() * r
|
33 |
extr = utils3d.torch.extrinsics_look_at(orig, torch.tensor([0, 0, 0]).float().cuda(), torch.tensor([0, 0, 1]).float().cuda())
|
34 |
-
intr = utils3d.torch.
|
35 |
extrinsics.append(extr)
|
36 |
intrinsics.append(intr)
|
37 |
if not is_list:
|
@@ -88,14 +88,15 @@ def render_frames(sample, extrinsics, intrinsics, options={}, colors_overwrite=N
|
|
88 |
|
89 |
|
90 |
def render_video(sample, resolution=512, bg_color=(0, 0, 0), num_frames=300, r=2, fov=40, **kwargs):
|
91 |
-
# Match the model viewer camera angle:
|
92 |
-
#
|
|
|
93 |
yaws = torch.linspace(0, 2 * 3.1415, num_frames) # Full rotation around Y-axis
|
94 |
-
pitch = torch.tensor([
|
95 |
yaws = yaws.tolist()
|
96 |
pitch = pitch.tolist()
|
97 |
-
#
|
98 |
-
r =
|
99 |
extrinsics, intrinsics = yaw_pitch_r_fov_to_extrinsics_intrinsics(yaws, pitch, r, fov)
|
100 |
return render_frames(sample, extrinsics, intrinsics, {'resolution': resolution, 'bg_color': bg_color}, **kwargs)
|
101 |
|
|
|
31 |
torch.sin(pitch),
|
32 |
]).cuda() * r
|
33 |
extr = utils3d.torch.extrinsics_look_at(orig, torch.tensor([0, 0, 0]).float().cuda(), torch.tensor([0, 0, 1]).float().cuda())
|
34 |
+
intr = utils3d.torch.intrinsics_from_fov_xy(fov, fov)
|
35 |
extrinsics.append(extr)
|
36 |
intrinsics.append(intr)
|
37 |
if not is_list:
|
|
|
88 |
|
89 |
|
90 |
def render_video(sample, resolution=512, bg_color=(0, 0, 0), num_frames=300, r=2, fov=40, **kwargs):
|
91 |
+
# Match the model viewer camera angle: isometric-like view
|
92 |
+
# Model viewer uses camera-orbit="45deg 75deg 100%" but that's spherical coords
|
93 |
+
# For render coordinates, we need a lower pitch angle for isometric view
|
94 |
yaws = torch.linspace(0, 2 * 3.1415, num_frames) # Full rotation around Y-axis
|
95 |
+
pitch = torch.tensor([20.0 * 3.1415 / 180.0] * num_frames) # Fixed pitch at 20 degrees (isometric-like)
|
96 |
yaws = yaws.tolist()
|
97 |
pitch = pitch.tolist()
|
98 |
+
# Use original distance to keep model in bounds
|
99 |
+
r = 2.0 # Back to original distance to prevent clipping
|
100 |
extrinsics, intrinsics = yaw_pitch_r_fov_to_extrinsics_intrinsics(yaws, pitch, r, fov)
|
101 |
return render_frames(sample, extrinsics, intrinsics, {'resolution': resolution, 'bg_color': bg_color}, **kwargs)
|
102 |
|