Alien Blitz 3d, lighting again, fog of war, shadow

Lighting

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

 

capture_2014-06-09_21-54-26_0439
(lights when color components are ignored, only intensity is used)

 

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.

 

capture_2014-06-09_21-49-18_0302
(lights when only colours are taken into account)

 

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.

 

capture_2014-06-09_22-03-38_0986
(current result)

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.

 

capture_2014-06-10_12-00-22_0548
(fog of war layer, red = undiscovered, green = discovered)

 

capture_2014-06-10_12-06-49_0123
(correct colours)

 

In order to display sprites under it the fog of war must be displayed after everything else, ignoring depth.

capture_2014-06-10_12-25-08_0480

In 2d for performance reason the fog of war layer is not very precise, trying a more precise one:

capture_2014-06-10_12-28-14_0204

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.

Shadows

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.

capture_2014-06-10_14-45-40_0819

Shadow is just an ellipse on the ground (minecraft style), its opacity depends on the distance with model

gif_2014-06-10_14-44-39_0831.original

I think all monsters and all bullets will have a shadow if it doesn’t increase load too much.

Comments are closed.