3D Isometric game engine in Blitz 3D – Generating Shadows

Whilst Blitz3D has a number of easy to use lighting effects, it lacks any built in shadow functionality.

An easy way to add a suggestion of a shadow is to use sprite shadows, a simple dark coloured sprite with some alpha set will cast a reasonable shadow effect.

Also with a bit of geometric knowhow, you can have shadows across the floor and up the walls.

snap0

In a room as in the picture above, if you have a single light source in the room, you would need to set up three potential shadows:

Shadow 1 – stretches across the floor between that man and the wall at the angle the man is to the flame. Dynamics for the shadow are positioning the centre of the sprite half way between the man and the wall at the flame to man angle, stretching it the correct length so that it reaches from man to wall and finally rotating it as the man moves in relation to the flame.

Shadow 2 – is on the east wall. Dynamics for this shadow are positioning it at the correct position on the wall so that its in line with the angle between flame and man and stretching it to the correct height so that its in line with the flame height to man height.

Shadow 3 – is on the north wall. Essentially its the same as shadow 2. Its far easier to have a north and east shadow so that when you reach the corner of the room, east shadow disappears into north wall as north wall shadow emerges out of east wall creating a nice shadow round the corner effect.

snap1

To add some atmosphere, animate the flame on the candle and in time with the animation:  increase/decrease the light range on the candle light to simulate some flame flicker, adjust your shadow angle by a couple of degrees left and right and slightly decrease/increase the alpha of the shadows.

snap2

The general lighting on all of the rooms above is biased towards blue. In order to set the general background lighting to a moonlight style colour, you need to up the blue in a big way. If you turn all of the lights off, you get a very heavy red/green biased low ambient light. To remove the red/green biasing you add blue light, but then you end up with a blue room…. so you up red green and blue but make blue double what red and green is to try and even the ambient light biasing out.

Leave a Reply

Your email address will not be published. Required fields are marked *