1

I am trying to produce shadows in a captured image in the Pybullet simulator. The shadows show up in the debugGUI mode but are not visible when calling p.getCameraImage even with shadow=True.

Something else I noticed is when shadow=True in p.getCameraImage there is a large shadow as if there is a tall object blocking the light rather than a small shadow corresponding to the object.

The issue persists whether connected to direct (p.connect(p.DIRECT)) or to GUI (p.connect(p.GUI)) as suggested here: https://github.com/bulletphysics/bullet3/issues/2610 and I have attached a minimum code sample below needed to reproduce the issue.

import pybullet as p
import pybullet_data
from PIL import Image
import math
physicsClient = p.connect(p.DIRECT)
p.setAdditionalSearchPath(pybullet_data.getDataPath())
p.configureDebugVisualizer(p.COV_ENABLE_SHADOWS, 1) # Shadows on/off

planeId = p.loadURDF("plane.urdf")
p.loadURDF("sphere_small.urdf",[0,0,0.2])
projectionMatrix = p.computeProjectionMatrixFOV(
    fov=90.0,
    aspect=16. / 9.,
    nearVal=0.1,
    farVal=30)
for i in range(360):
    viewMatrix = p.computeViewMatrix(
        cameraEyePosition=[2*math.cos(math.radians(i)), 2*math.sin(math.radians(i)),2],
        cameraTargetPosition=[0.0, 0, 0],
        cameraUpVector=[0, 0, 1])
    width, height, rgbImg, depthImg, segImg = p.getCameraImage(
        width=int(1280),
        height=int(720),
        viewMatrix=viewMatrix,
        projectionMatrix=projectionMatrix,
        shadow=True
    )
    im = Image.fromarray(rgbImg)
    im.save('imgs/test/' + str(i) + ".png")
  • It seems as if this was a known problem: https://github.com/bulletphysics/bullet3/issues/2206 But it is unclear if it has been resolved anywhere. – avgJoe Mar 01 '22 at 16:40

0 Answers0