-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Description
It seems that the OpenGL rendering size is set once for mujoco enviroments instead of using the actual width and height provided to the MujocoRenderer
Gymnasium/gymnasium/envs/mujoco/mujoco_env.py
Line 124 in cde2f60
| model.vis.global_.offwidth = self.width |
I used the MujocoRenderer to create a custom renderer with a different size, but this causes black bands on the part outside of the original size.
renderer = MujocoRenderer(
env.unwrapped.model,
env.unwrapped.data,
None,
width=width,
height=height,
camera_name=camera_name,
)
img = renderer.render(render_mode)
Shouldn't the OpenGL size be set inside the renderer before creating the screen? i.e. here
I changed the code like his
# save the original width and height of the model to restore it later
orig_width = self.model.vis.global_.offwidth
orig_height = self.model.vis.global_.offheight
# set the width and height to the context, otherswise the rendering will have black bands if the resolution differs from the one with which the gym env was created.
self.model.vis.global_.offwidth = self.width
self.model.vis.global_.offheight = self.height
self.viewer = OffScreenViewer(
self.model,
self.data,
self.width,
self.height,
self.max_geom,
self._vopt,
)
# restore the default width and height to the context
self.model.vis.global_.offwidth = orig_width
self.model.vis.global_.offheight = orig_height
which solved the black bands for me:
Not an expert on mujoco rendering though, so I might be overlooking something.
Metadata
Metadata
Assignees
Labels
No labels