Shadows sample: light camera moving with real camera


I’ve been trying to integrate the shader-based shadows from the shadows sample program into my code [0]. With just copying that code and adapting the shader file paths, I observe strange behaviour: the light camera (LCam in code) moves with the real camera as if it was attached to it, although this never happens in code. At least thats what I’m concluding from the color map view, which is the LCam’s perspective as far as I understand the sample code. Can you tell me what is going wrong there?

I’ve put up a mostly minimal example that still sits on my code base which makes it easier to move around. If you want to run it, I can prepare a tarball.

My example:
(Relevant shader code at === Shaders ===)

[0]: Using the “experimental” shadows subfolder because only that one runs on Intel graphics.

Hey, one of the shadow examples works out of the box on my Intel GM45 now :slight_smile:

I encountered this problem a while back - I think the fix is to make a new PerspectiveLens for the shadow camera instead of cloning the actual camera. I could be wrong, but IIRC that’s what worked for me.

I thought that is exactly the Intel-compatible code you posted on diaspora a while ago and that is now in the panda distribution, isn’t it? :smiley:

About (not) cloning the camera: doesn’t

self.LCam = base.makeCamera(LBuffer)

create a new one? (Line 121 in my paste)

How would I do that if not?



before configuring the LCam’s lens doesn’t help. and contains the code for the fixed example - I never submitted the changes (which revolved around GraphicsOutput.RTPDepth malfunctioning - it works now) to rdb, so I doubt the patches made their way into Panda.

When I get the chance, I’ll compare your code to what I wrote, and see if I can find any differences.

Ha, thanks!

After fiddling a little with the camera I have … shadows. They just appear about 1 unit below the ground, getting visible when I jump over things with the vehicle. And my models are pitch black, just the GeomipTerrain is lighted more or less as expected. Very interesting. Seems like its time to learn a little Cg myself… :slight_smile: