This meant that implementing and maintaining good looking shadows within the game code became much easier.
For example, setting up shadows becomes as simple as including the following code (not shown complete/in order);
- Code: Select all
xInitShadows(512 * SHADOW_QUALITY, 0, 0)
xLightEnableShadows LIGHT, 1
xSetShadowParams 4, 0.95, True, 300
xLightShadowEpsilons LIGHT, 0.0001, 0.6
Interestingly, setting shadows on all scenery within a level actually detracted from the visual appearance.
This is due to the tiles that make up a level already having some diffuse global illumination 'baked in' via a lightmap (calculated in Giles).
Adding strong shadows to this subtle shading simply looked 'wrong'.
However, setting shadows on the smaller, AI objects such as tanks, does seem to work as it helps to 'pop' out these items from the surrounding geometry. I guess this is in line with TU2's design philosophy that important game elements should be visually more 'explicit' and than background static elements.
Shadow casting on medium tanks.
End of an era?
TU1 was developed using Blitz3d - which has been a great little utility; there's a load of public domain libs available and it allowed me to get the job done and finish my first published game.Viva la Blitz!
However, speed was always an issue. In a game like TU2 where there's a large number of AI units running around doing their own thing, Blitz3d's mediocre performance is a problem.
Xors3d can be bolted onto Blitz3d, which does help to speed up the graphics handling, but this doesn't affect Blitz3d's base code execution speed. So what to do? (apart from optimise as much as possible)
Blitz3d has a sucessor in the form of BlitzMax - which is considerably faster and more sophisticated than Blitz3d (http://www.blitzbasic.com)
It doesn't have a native 3d engine but Xors3d can be bolted onto it and because Xors3d uses Blitz3d's commandset, I could see my way to porting the code.
This took a bit of time - there was a lot of stepping through and replacing changed syntax. Blitzmax does have a Blitz3d import function, but it's not perfect and I had about 60+ project files to work through. Luckily, this kind of grunt work can be done by making judicious use of the find and replace function while keeping half an eye or ear on youtube documentaries, so it wasn't as blindingly tedious as it could have been.
The end result is a considerable speed up in code execution. Haven't done a direct comparision, but possibly up to twice again, which is very nice to have.
Having said that, there are drawbacks. For one, the GUI lib TU2 has been using - SpriteCandy - is not available for Blitzmax.
Hopefully something similar will appear shortly that allows me to avoid having to recode all that functionality.