Figured out why my frustum was not showing: its the same color as the bacground. Now that I have it showing, for the directional light it only shows a single line, which I don’t know if that’s all I’m supposed to see. It points in the exact direction I want it to, and it seems to be long enough to cast shadows, yet it isn’t
Yours is not the first report of shadows working with a Spotlight but not with a DirectionalLight. Unfortunately, the people who originally wrote the shadow code are no longer around, so no one here can say definitively whether it’s supposed to work the way you’re using it–but I agree it does seem broken.
If you or anyone else would be interested in researching the problem further, we’d be happy to accept patches.
Yeah, Ive also spend many hours trying to get shadows working with other lights properly. They don’t, it’s just how the shadow effect was implemented in Panda. It would be great if someone would write a proper shadow shader to work with most lights and the shader generator. There are many shadow shader examples here, but of course none works with the shader generator. Most people here don’t have any shader programming knowledge or C++ knowledge to do it.
Shadows are a common thing you’ll want from a game. I actually considered switching to PyOgre for my project because of this. I wouldn’t suggest that though, Panda has alot more pros.
There’s no reason why DirectionalLight wouldn’t work just like the Spotlight (even though it’s more difficult to set up, and may cause visual artifacts due to the nature of an orthogonal shadow map). It’s just a matter of configuring the frustum correctly to fit around both the objects that receive shadows and cast shadows.
If the frustum is in place properly (and you can verify this using showFrustum), and it’s still not showing up, then it’s probably a bug in your video drivers because the code is so similar to the code for a spot light. There could be a bug in Panda, of course, and I could look into that if you could send me a working small test case that I can reproduce the problem with.
@Anon: I’ve heard you complain many times about the shadow system, but so far I haven’t seen any bug reports on Launchpad from you about it. If it’s really bothering you that much, why not help us resolve the problems by giving us enough information to work with, perhaps a test case?
I guess it sounds like rant, sorry about that. It’s mainly because every time I encounter this, I try to learn Cg again to solve it myself and fail miserably.
I don’t think it’s a bug,so I don’t think I can post it in Launchpad. There was a topic where I posted my code and issues and was told that the shadow system was meant to be used with spotlights. If you want I can dig up the codes and example screens.
I remember your old topic about the issue. I went back to it a few months after you made it, tried your code and I got it to work flawlessly with just a few tweaks. I didn’t post the results back to the thread because it was so old.
As for why spotlights are preferred: there’s not much to do about that. Perspective cameras (especially with a properly tweaked FOV and near/far ratio) tend to work better with shadow mapping in general because the depth map is not linear and because the frustum is not parallel. If you insist on using directional lights with shadows, it is crucial that the frustum is tweaked as efficiently as possible.
Perhaps I should make a video tutorial explaining how to easily and effectively tweak the shadow system, do you think that would help?
If I could use a lens node for shadows, or spotlight which wouldn’t be used as a an actual light, then it works for me. The only reason I want directional light is because my scene is meant to use Directional light (for the sun).
Well that would be great and I think it would be pretty helpful to everyone, but I think I coud understand by an ordinary post.