Casting shadows from billboard

Hi guys,

I’m in the process of making a 2.5d platformer (2D guy in a 3D world), and I am running into some shadowing problems.

I am using Panda3D’s automatic shadow mapping functionnality, and my 2D billboard doesn’t cast shadows. Here, to give you an idea of the setup (sorry, it’s pretty dark), you can see the light is on the left, and casts light on the floor and wall, with the character standing in the room.

So here, no shadow, as the billboard is aligned with the light’s direction. But, now, turning the scene 90° :

Here I would have expected a shadow cast from the base of the sprite. Is that juste impossible to do ? Or do I need some more magic ?

Thanks in advance !

My guess is the fact that billboards are infinitely thin - and thus, have no backfaces - are messing up Panda’s shadow mapping shader. Try enabling double-sided rendering on the billboard - done with NodePath.setTwoSided(True), if I recall correctly.

Thanks, I will try that.

But on the other hand, the billboarding could have been applied to any NodePath, so I’m not sure there is a fundamental difference between the billboarded plane I’m using for the character and the planes making up the room (they have no depth, they are simple, one-sided planes).

I will get back to you as soon as I have had a chance to test your solution, then :slight_smile:

You could also try using a simple model of the character only for shadows calculation, which is invisible to the camera and visible to the light.

Yes, I thought about that. But that would mean I need to animate it :\ Currently, I’m using a placeholder character from, but as much as I can see myself try to do something decend in 2D, making, and animating a 3D character is a much tougher challenge.

I also wonder how I would “synchronize” the shadows during the animation. Wouldn’t the difference between the shadow’s “smooth” movements and the sprites’ (limited by the number of animation frames) be somewhat jarring ?

Sure, but it is a model for a shadow, it doesn’t need to be too accurate, you could try doing one and see if its shadow actually sucks or not.

You could make a relation between the sprites and the positions of the animation, and set the corresponding position for each frame swapping.

Anyway, surely you are right if you need precise shadows. But this is not the case for many games: there are also games without shadows, baked shadows (not for characters, obviously), blob shadows (and, obviously, there are also games with more realistic shadows). So, shadows are often an approximation, if you can make a decent approximation with a 3d model I would be very happy as a player. This is just an opinion. :wink: