DirectionalLight Shadow Bug?

I am trying to learn about shadows in panda, and I have a simple example setup that exhibits some strange behavior. I am sure that I have done something wrong with the DirectionalLight lens setup, but it appears that the shadows are flipped. Notice the shadow cast by the small cube on to the large cube. Here is an example:

Here is the basic code:

box1 = loader.loadModel(‘box’)
box1.setScale(10)
box1.setPos(10,-25,75)
box1.reparentTo(render)

box2 = loader.loadModel(‘box’)
box2.setScale(50)
box2.reparentTo(self.render)
box2.setShaderAuto()

dlight = DirectionalLight(‘dlight’)
dlight.setShadowCaster(True, 512, 512)
dlnp = render.attachNewNode(dlight)
dlnp.node().showFrustum()
dlnp.node().getLens().setFilmSize(128, 128)
dlnp.setPos(0,0,100)
dlnp.setHpr(0,-90, 0)
render.setLight(dlnp)

Anybody know what might be going on here?

Hmm…

Trying out your code on my system (with a few minor modifications, such as placing the camera at the position and orientation shown in your post), the shadows seem to be as expected, quite unlike your screenshot.

What version of Panda are you using? If you’re perhaps using a version older than 1.10.6, then perhaps it’s worth upgrading and seeing whether this is the result of some now-fixed engine-bug.

I am running the latest master, which is 1.10.6.post2

Hmm, very odd. What are you system specs, if I may ask? And would you please post the rest of your code–perhaps something there is interfering with the shadows in this way.

Sorry, I am on 1.11.0
Here is code, and still the same result.

from direct.showbase.ShowBase import ShowBase
from panda3d.core import DirectionalLight

import panda3d
print(panda3d.__version__)

class MyApp(ShowBase):

	def __init__(self):
		ShowBase.__init__(self)

		box1 = loader.loadModel('box')
		box1.setScale(10)
		box1.setPos(10,-25,75)
		box1.reparentTo(self.render)

		box2 = loader.loadModel('box')
		box2.setScale(50)
		box2.reparentTo(self.render)
		box2.setShaderAuto()

		dlight = DirectionalLight('dlight')
		dlight.setShadowCaster(True, 512, 512)
		dlnp = self.render.attachNewNode(dlight)
		dlnp.node().showFrustum()
		dlnp.node().getLens().setFilmSize(128, 128)
		dlnp.setPos(0,0,100)
		dlnp.setHpr(0,-90, 0)
		self.render.setLight(dlnp)


app = MyApp()
app.run()

here are my system specs:

H/W path             Device     Class          Description
==========================================================
                                system         20QVCTO1WW (LENOVO_MT_20QV_BU_Think_FM_ThinkPad X1 Ext
/0                              bus            20QVCTO1WW
/0/3                            memory         32GiB System Memory
/0/3/0                          memory         16GiB SODIMM Synchronous 2667 MHz (0.4 ns)
/0/3/1                          memory         16GiB SODIMM Synchronous 2667 MHz (0.4 ns)
/0/d                            memory         384KiB L1 cache
/0/e                            memory         1536KiB L2 cache
/0/f                            memory         12MiB L3 cache
/0/10                           processor      Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
/0/11                           memory         128KiB BIOS
/0/100                          bridge         8th Gen Core Processor Host Bridge/DRAM Registers
/0/100/1                        bridge         Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor PCIe
/0/100/1/0                      display        NVIDIA Corporation
/0/100/1/0.1                    multimedia     NVIDIA Corporation
/0/100/2                        display        Intel Corporation
/0/100/4                        generic        Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor Ther
/0/100/8                        generic        Xeon E3-1200 v5/v6 / E3-1500 v5 / 6th/7th Gen Core Pro
/0/100/12                       generic        Cannon Lake PCH Thermal Controller
/0/100/14                       bus            Cannon Lake PCH USB 3.1 xHCI Host Controller
/0/100/14/0          usb1       bus            xHCI Host Controller
/0/100/14/0/1                   input          Wireless Device
/0/100/14/0/8                   multimedia     Integrated Camera
/0/100/14/0/9                   generic        Generic USB device
/0/100/14/1          usb2       bus            xHCI Host Controller
/0/100/14.2                     memory         RAM memory
/0/100/15                       bus            Intel Corporation
/0/100/16                       communication  Cannon Lake PCH HECI Controller
/0/100/1b                       bridge         Intel Corporation
/0/100/1b/0                     storage        NVMe SSD Controller SM981/PM981
/0/100/1b.4                     bridge         Cannon Lake PCH PCI Express Root Port 21
/0/100/1b.4/0                   bridge         JHL7540 Thunderbolt 3 Bridge [Titan Ridge 4C 2018]
/0/100/1b.4/0/0                 bridge         JHL7540 Thunderbolt 3 Bridge [Titan Ridge 4C 2018]
/0/100/1b.4/0/0/0               generic        JHL7540 Thunderbolt 3 NHI [Titan Ridge 4C 2018]
/0/100/1b.4/0/1                 bridge         JHL7540 Thunderbolt 3 Bridge [Titan Ridge 4C 2018]
/0/100/1b.4/0/2                 bridge         JHL7540 Thunderbolt 3 Bridge [Titan Ridge 4C 2018]
/0/100/1b.4/0/2/0               bus            JHL7540 Thunderbolt 3 USB Controller [Titan Ridge 4C 2
/0/100/1b.4/0/2/0/0  usb3       bus            xHCI Host Controller
/0/100/1b.4/0/2/0/1  usb4       bus            xHCI Host Controller
/0/100/1b.4/0/4                 bridge         JHL7540 Thunderbolt 3 Bridge [Titan Ridge 4C 2018]
/0/100/1c                       bridge         Intel Corporation
/0/100/1c/0                     generic        Genesys Logic, Inc
/0/100/1d                       bridge         Cannon Lake PCH PCI Express Root Port 9
/0/100/1d/0                     storage        Micron/Crucial Technology
/0/100/1d.6                     bridge         Intel Corporation
/0/100/1d.6/0        wlp82s0    network        Wireless-AC 9260
/0/100/1e                       communication  Intel Corporation
/0/100/1f                       bridge         Intel Corporation
/0/100/1f.3                     multimedia     Cannon Lake PCH cAVS
/0/100/1f.4                     bus            Cannon Lake PCH SMBus Controller
/0/100/1f.5                     bus            Cannon Lake PCH SPI Controller
/0/100/1f.6          enp0s31f6  network        Ethernet Connection (7) I219-V
/1                              power          5B10V98091

Very strange indeed: I quickly installed 1.11 (specifically, 1.11.0.dev1736), and I’m still not getting the anomalous behaviour that you’re seeing.

If you’re not already using the version that I just referenced, I’d suggest trying that–perhaps it’s a regression of some sort between versions.

What happens if you run the sample programs that cover shadows? Do either of those produce correct-looking shadows?

Two more thoughts:

  1. Have you updated your video-drivers?
  2. If I’m inferring correctly, you have both an NVidia graphics card and an Intel one; are you sure that the NVidia card is set to handle the rendering of such programs as this?

I just had a buddy try on his machine running panda version 1.10.5 and he has the same problem. His system is a dell, with a GTX 1050ti mobile.

I have a monoblock with a GTX 1050 video card, and I don’t see this problem on Panda version 1.10.6.

My best ideas right now remain as I posted above. I suggest the following, in no particular order:

  • Try Panda version 1.11.0.dev1736, if you’re not already using that specific version.
  • Try the shadow-casting sample-programs, and see whether they look correct.
  • Check whether your video drivers might perhaps be updated
  • Check that your NVidia card is indeed the one being applied to the program, and not your Intel one.

Two more thoughts:

  • Try running (an API-based–i.e. not a distributable build–version of) the program from the command-line, and see whether there’s any error output.
  • If you’re using the Nouveau drivers for your NVidia card, perhaps try the NVidia-sourced open-source ones. (I’m using the driver labelled “410”, I believe.)

Thanks for the suggestions, I’ll check it out.

1 Like