@@ -354,9 +354,9 @@ def _floor_pass(self, scene, flags, seg_node_map=None, env_idx=-1):
354354 glClearColor (0.0 , 0.0 , 0.0 , 1.0 )
355355 glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT )
356356
357- V , P = self ._get_camera_matrices (scene )
357+ V , P = self ._get_camera_matrices (scene , env_idx )
358+ cam_pose = self ._get_camera_pose (scene , env_idx )[:3 , 3 ]
358359
359- cam_pos = scene .get_pose (scene .main_camera_node )[:3 , 3 ]
360360 screen_size = np .array ([self .viewport_width , self .viewport_height ], np .float32 )
361361
362362 self .jit .forward_pass (
@@ -391,8 +391,8 @@ def _forward_pass(self, scene, flags, seg_node_map=None, env_idx=-1):
391391 glEnable (GL_MULTISAMPLE )
392392
393393 # Set up camera matrices
394- V , P = self ._get_camera_matrices (scene )
395- cam_pos = scene . get_pose (scene . main_camera_node )[:3 , 3 ]
394+ V , P = self ._get_camera_matrices (scene , env_idx )
395+ cam_pos = self . _get_camera_pose (scene , env_idx )[:3 , 3 ]
396396
397397 floor_tex = self ._floor_texture_color ._texid if flags & RenderFlags .REFLECTIVE_FLOOR else 0
398398 screen_size = np .array ([self .viewport_width , self .viewport_height ], np .float32 )
@@ -455,7 +455,7 @@ def _normal_pass(self, scene, flags, env_idx=-1):
455455 program = None
456456
457457 # Set up camera matrices
458- V , P = self ._get_camera_matrices (scene )
458+ V , P = self ._get_camera_matrices (scene , env_idx )
459459
460460 # Now, render each object in sorted order
461461 for node in scene .sorted_mesh_nodes ():
@@ -690,15 +690,25 @@ def _reset_active_textures(self):
690690 # Camera Matrix Management
691691 ###########################################################################
692692
693- def _get_camera_matrices (self , scene ):
693+ def _get_camera_matrices (self , scene , env_idx ):
694694 main_camera_node = scene .main_camera_node
695695 if main_camera_node is None :
696696 raise ValueError ("Cannot render scene without a camera" )
697697 P = main_camera_node .camera .get_projection_matrix (width = self .viewport_width , height = self .viewport_height )
698- pose = scene . get_pose ( main_camera_node )
698+ pose = self . _get_camera_pose ( scene , env_idx )
699699 V = np .linalg .inv (pose ) # V maps from world to camera
700700 return V , P
701701
702+ def _get_camera_pose (self , scene , env_idx ):
703+ cam_pos = scene .get_pose (scene .main_camera_node )
704+ if len (cam_pos .shape ) == 3 :
705+ if cam_pos .shape [0 ] != 1 :
706+ assert env_idx != - 1 , "We have a multiple camera pose scene, we should be rendering per env"
707+ cam_pos = cam_pos [env_idx ]
708+ else :
709+ cam_pos = cam_pos [0 ]
710+ return cam_pos
711+
702712 def _get_light_cam_matrices (self , scene , light_node , flags ):
703713 light = light_node .light
704714 pose = scene .get_pose (light_node )
0 commit comments