Casting shadows from billboard

Return to Scripting Issues

Casting shadows from billboard

Postby Grungi Ankhfire » Sun Jun 17, 2012 5:26 am

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.

Image

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

Image

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 !
Grungi Ankhfire
 
Posts: 19
Joined: Fri Nov 27, 2009 6:10 am
Location: Belgium

Postby DangerOnTheRanger » Sun Jun 17, 2012 2:18 pm

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.
Free + open-source game development kit: http://openblox.sourceforge.net

My blog: http://dangerontheranger.blogspot.com
User avatar
DangerOnTheRanger
 
Posts: 240
Joined: Fri Aug 27, 2010 4:59 pm

Postby Grungi Ankhfire » Mon Jun 18, 2012 3:10 am

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 :)
Grungi Ankhfire
 
Posts: 19
Joined: Fri Nov 27, 2009 6:10 am
Location: Belgium

Postby flavio » Mon Jun 18, 2012 3:13 am

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.
Image - Image
User avatar
flavio
 
Posts: 530
Joined: Fri Apr 16, 2010 12:45 pm
Location: Rome, Italy

Postby Grungi Ankhfire » Mon Jun 18, 2012 3:17 am

Yes, I thought about that. But that would mean I need to animate it :\ Currently, I'm using a placeholder character from OpenGameArt.org, 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 ?
Grungi Ankhfire
 
Posts: 19
Joined: Fri Nov 27, 2009 6:10 am
Location: Belgium

Postby flavio » Mon Jun 18, 2012 4:31 am

Grungi Ankhfire wrote:Yes, I thought about that. But that would mean I need to animate it :\ Currently, I'm using a placeholder character from OpenGameArt.org, 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.

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.
Grungi Ankhfire wrote: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 ?

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. ;)
Image - Image
User avatar
flavio
 
Posts: 530
Joined: Fri Apr 16, 2010 12:45 pm
Location: Rome, Italy


Return to Scripting Issues

Who is online

Users browsing this forum: No registered users and 1 guest