Shadows: direction, parameters, and inputs in GLSL

[edit 2]

For now I think that I’ve found a solution that works for me:

I’m honestly not sure of how to properly integrate Panda lights with a custom shader in 1.9: While 1.10 provides direct access to the shadow-buffer in the light-properties struct, I’m not finding an obvious way to access it in 1.9. While LightLensNode does have the “getShadowBuffer” method, it description indicates that it’s not intended for non-debugging use, and when I attempted to use it anyway I believe that it returned “None”. I could use the buffers that I’ve been creating under the tutelage of the “advanced shadows” tutorial, but I don’t see a means of connecting them to a light.

On top of that, my current lighting algorithm doesn’t use most of the parameters given by the light-properties struct.

As a result, I’ve returned to the method provided by the “advanced shadows” tutorial, simply creating cameras and then using “setShadowInput” to providing those parameters that I’m using.

I solved the issue of the light-direction by transforming the vector (0, 0, -1, 0) via the matrix “trans_clip_of_mainLight_to_model”–that is, if I’m not much mistaken, taking a vector defined as pointing in the negative z-direction in the light’s space and transforming it into model-space. This seems to work as expected.

[/edit 2]

… But a light’s apparent direction shouldn’t be affected by the camera’s orientation unless that light is intended to be attached to the camera, surely?

[edit]
Argh, right, I see what you’re saying. Sorry, I fear that lack of sleep might be getting to me a bit. >_<;

All right, I’m doing my lighting in model-space, so I’ll want to transform the “position” value of my directional light–easily-enough done, I believe.
[/edit]

Ah, right–sorry, I seem to have missed or forgotten that somehow. ^^;

Hmm… That’s a concern–I wasn’t aware of the portability issue. I think that I chose 1.20 simply because it was the version that I was familiar with, and the version that I found least difficult to adapt my extant shaders to when I started in on these shadow-shaders. I also don’t want to push the version too high for fear of limiting my potential user-base. In that case, would you recommend 1.30, or even higher?

Ah, I feel silly for having missed that–sorry! ^^;

Right, that does seem to have an effect. Noting that I haven’t yet had another shot at integrating your code above, and am thus still using my own (which uses “row2_mainLight_to_model.xyz” for the light’s direction), it it doesn’t seem to fix the problem: a light with HPR of (-45, -45, 0) now produces light on the left- and front- sides of a cube (as expected), but also on the underside, with a self-shadow partially obscuring it. The top, which I would expect to be lit, isn’t.

Changing the pitch to 45 causes the back- and right- sides to be lit, with the bottom still lit, but no longer self-shadowed (presumably a result of the self-shadow falling onto the already-dark upper side).

Given your explanation above, however, I intend to try again at using your code given above, along with a move to GLSL 1.30 (I can port to a higher version again if called for; porting to 1.30 should, from what you’ve said, at least get me the functionality that you’ve described).

Ah, thank you–that looks like a useful overview! :slight_smile: