Genesis icon indicating copy to clipboard operation
Genesis copied to clipboard

Error of rendering the shadow

Open zez626 opened this issue 1 year ago • 3 comments

Bug Description

You can see the error in the generated video, the shadow disappered after the shadow get out of a box. You can use the following code to reproduce it.

Steps to Reproduce

import genesis as gs
import os
os.environ['PYOPENGL_PLATFORM'] = 'glx'

DT = 1.0 / 30

gs.init(backend=gs.cuda)

vis_options = gs.options.VisOptions(show_world_frame=False)
scene = gs.Scene(
    sim_options=gs.options.SimOptions(dt=DT, gravity=(0, 0, -9.81)),
    show_viewer=False,
    vis_options=vis_options 
)

ground = scene.add_entity(
    morph=gs.morphs.Plane(pos=(0.0, 0.0, 0.0), normal=(0, 0, 1)),
    material=gs.materials.Rigid(),
    surface=gs.surfaces.Default(color=(0.0, 0.0, 1.0, 1.0))  # Blue
)

pos = (0.0, 0.0, 1.5)

velocity = (
    1.0, # X velocity
    -0.5,    # Y velocity
    2.0,    # Z velocity
    0.0, 0.0, 0.0  # No initial angular velocity
)

radius = 0.2
ball = scene.add_entity(
    morph=gs.morphs.Sphere(pos=pos, radius=radius),
    material=gs.materials.Rigid(),
    surface=gs.surfaces.Default(color=(1.0, 0.0, 0.0, 1.0))  # Red
)

camera = scene.add_camera(
    res=(640, 480),
    pos=(3.0, 3.0, 2.0),
    lookat=(0.0, 0.0, 0.5),
    fov=45,
    GUI=False
)

scene.build()

ball.set_dofs_velocity(velocity)

camera.start_recording()
for step in range(300):
    scene.step()
    camera.render()
camera.stop_recording(save_to_filename="synthetic_data/single_object/ball_projectile_motion.mp4", fps=30)

https://github.com/user-attachments/assets/6e98ba91-5fa9-482a-8504-031853c53d88

zez626 avatar Jun 14 '25 11:06 zez626

Can you upload the video again? I cannot open it.

duburcqa avatar Jun 16 '25 07:06 duburcqa

There is indeed an issue with shadow rendering. It is clipped to some rendering area:

Image

duburcqa avatar Jun 16 '25 08:06 duburcqa

For the record, here is a more minimal reproduction script:

import genesis as gs

gs.init(backend=gs.cpu)

scene = gs.Scene(
    vis_options=gs.options.VisOptions(show_world_frame=False),
    show_viewer=True,
)

ground = scene.add_entity(
    morph=gs.morphs.Plane(pos=(0.0, 0.0, 0.0), normal=(0, 0, 1)),
)
ball = scene.add_entity(
    morph=gs.morphs.Sphere(pos=(0.0, 0.0, 1.5), radius=0.2),
)
scene.build()

ball.set_dofs_velocity((1.0, -0.5, 2.0), (0, 1, 2))
for step in range(60):
    scene.step()
scene.viewer.run()

duburcqa avatar Jun 16 '25 08:06 duburcqa