+7
-3
@@ -321,7 +321,11 @@ class RenderSMPLMesh:
|
||||
"required": {
|
||||
"smpl": ("SMPL", ),
|
||||
"draw_platform": ("BOOLEAN", {"default": False}),
|
||||
"depth_only": ("BOOLEAN", {"default": False})
|
||||
"depth_only": ("BOOLEAN", {"default": False}),
|
||||
"yfov": ("FLOAT", {"default": 3,"min": 0.1, "max": 10, "step": 0.1}),
|
||||
"move_x": ("FLOAT", {"default": 0,"min": -500, "max": 500, "step": 0.1}),
|
||||
"move_y": ("FLOAT", {"default": 0,"min": -500, "max": 500, "step": 0.1}),
|
||||
"move_z": ("FLOAT", {"default": 0,"min": -500, "max": 500, "step": 0.1}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,9 +333,9 @@ class RenderSMPLMesh:
|
||||
RETURN_NAMES = ("IMAGE", "DEPTH_MAP")
|
||||
CATEGORY = "MotionDiff/smpl"
|
||||
FUNCTION = "render"
|
||||
def render(self, smpl, draw_platform, depth_only):
|
||||
def render(self, smpl, yfov, move_x, move_y, move_z, draw_platform, depth_only):
|
||||
motion_tensor, _ = smpl
|
||||
color_frames, depth_frames = render_from_smpl(motion_tensor.to(get_torch_device()), draw_platform, depth_only)
|
||||
color_frames, depth_frames = render_from_smpl(motion_tensor.to(get_torch_device()),yfov, move_x, move_y, move_z, draw_platform,depth_only)
|
||||
color_frames = torch.from_numpy(color_frames[..., :3].astype(np.float32) / 255.)
|
||||
|
||||
#Normalize to [0, 1]
|
||||
|
||||
@@ -156,7 +156,7 @@ def render(motions):
|
||||
out = np.stack(vid, axis=0)
|
||||
return out
|
||||
|
||||
def render_from_smpl(motion_tensor, draw_platform=True, depth_only=False):
|
||||
def render_from_smpl(motion_tensor, yfov, move_x, move_y, move_z, draw_platform=True, depth_only=False):
|
||||
rot2xyz = Rotation2xyz(device=get_torch_device())
|
||||
faces = rot2xyz.smpl_model.faces
|
||||
|
||||
@@ -205,8 +205,8 @@ def render_from_smpl(motion_tensor, draw_platform=True, depth_only=False):
|
||||
|
||||
sx, sy, tx, ty = [0.75, 0.75, 0, 0.10]
|
||||
|
||||
camera = pyrender.PerspectiveCamera(yfov=(np.pi / 3.0))
|
||||
|
||||
camera = pyrender.PerspectiveCamera(yfov)
|
||||
|
||||
light = pyrender.DirectionalLight(color=[1,1,1], intensity=300)
|
||||
|
||||
scene.add(mesh)
|
||||
@@ -235,14 +235,25 @@ def render_from_smpl(motion_tensor, draw_platform=True, depth_only=False):
|
||||
|
||||
c = -np.pi / 6
|
||||
|
||||
scene.add(camera, pose=[[ 1, 0, 0, (minx+maxx).cpu().numpy()/2],
|
||||
x_translation = move_x # Your X-axis translation value
|
||||
y_translation = move_y # Your Y-axis translation value
|
||||
z_translation = move_z # Your Z-axis translation value
|
||||
|
||||
[ 0, np.cos(c), -np.sin(c), 1.5],
|
||||
initial_pos = [(minx+maxx).cpu().numpy()/2 + x_translation,
|
||||
y_translation,
|
||||
max(4, minz.cpu().numpy()+(1.5-MINS[1].cpu().numpy())*2, (maxx-minx).cpu().numpy()) + z_translation]
|
||||
|
||||
[ 0, np.sin(c), np.cos(c), max(4, minz.cpu().numpy()+(1.5-MINS[1].cpu().numpy())*2, (maxx-minx).cpu().numpy())],
|
||||
pose = [[ 1, 0, 0, initial_pos[0]],
|
||||
[ 0, np.cos(c), -np.sin(c), 1.5 + initial_pos[1]],
|
||||
[ 0, np.sin(c), np.cos(c), initial_pos[2]],
|
||||
[ 0, 0, 0, 1]
|
||||
]
|
||||
|
||||
[ 0, 0, 0, 1]
|
||||
])
|
||||
# Add the camera to the scene with the modified pose
|
||||
scene.add(camera, pose=pose)
|
||||
|
||||
# Add the camera to the scene with the modified pose
|
||||
scene.add(camera, pose=pose)
|
||||
|
||||
# render scene
|
||||
r = pyrender.OffscreenRenderer(960, 960)
|
||||
|
||||
Reference in New Issue
Block a user