Some more modifications to lighting as “natural light” was not working, natural light is a light that does not add color, a white light.
In Alien Blitz a light has 5 parameters : red / green / blue / color intensity / intensity
A pure white light will have a color intensity of 0, an intensity of 1, and anything as red/green/blue components
A “toxic light” (green light) will have an high color intensity (around 1), an intensity depending on ambient light or if another light is near, and a green color component.
Problem is I can only send 4 parameters to the shader at the moment, previously I was not sending intensity, meaning natural lights were not working. So I’ve cheated a bit to try to render everything.
As a result lights are now less colored, and full natural light is a bit greyish. It’s ok but it would be better if I could find a better solution.
Fog of war
One of the thing I added in Alien Blitz 1.1 is fog of war, and I really liked that so it had to be implemented.
In 2d fog of war is just a texture applied above everything that gets updated when player moves and discover new terrain (not very good as it implies more CPU/GPU communication, but the fog of war is not updated a lot, so that’s ok)
In 3d I’m just using the very same texture, applied to a simple mesh on top of the level.
In order to display sprites under it the fog of war must be displayed after everything else, ignoring depth.
In 2d for performance reason the fog of war layer is not very precise, trying a more precise one:
There are a few problems as it’s not a top view:
- Some hidden things on top are sometimes visible, depending on camera angle
- Some things at the bottom are not visible at all
This can be easily changed in the code, but will be done later.
Something more precise could be done, with a more complicated mesh above every voxel, but current solution is good enough for mobile, maybe I will consider it on PC.
Now that we are in 3d shadows need to be implemented. Shadows are available in Snorms isometric view, but were removed in top view 2d as they were useless.
Shadow is just an ellipse on the ground (minecraft style), its opacity depends on the distance with model
I think all monsters and all bullets will have a shadow if it doesn’t increase load too much.