Light and dark

Posted July 24th, 2013 by Tynan Sylvester

I’ve been working hard on improving the look of the game.

Here’s a shot before the latest improvements. This is tester screeching_goat fighting hard to survive a tough raider attack (she failed). This shot one has an early version of edge shadowing in it – see if you can tell the difference from later shots.


The graphical improvements have come in four subsystems.

Character graphics

Previously, every character was represented by a colored dot. Now, each person has a body model that corresponds to their key adulthood history item. So, an ex-farmer oaf will be a big fat dude. An ex-scientist is a thin figure wearing a suggestion of a lab coat. A noble wears purple. These characters have three frames of animation (front/side/back) that they switch between as them move around to give a sense of interactivity to their movements.

Heads are tracked separately and chosen randomly for each character based on their sex. So the overall identity of a person decodes visually as: Body shape indicates archetype, head indicates individual identity.

I hope players will be able to get to know their characters more easily this way. I think people respond well to classical archetypical characters and I want your colonists and enemies to express these. It’s as much about expressing personality as it is about telling characters apart or looking pretty. Because this game really revolves around character.

Edge shadows

This was a straightforward system, but worth mentioning. Edge shadows now wrap around the base of every tall object in the game. To do this, the game generates a mesh that wraps around the edges of tall objects every time the world changes. The vertex colors of the mesh are set to be dark near the object, fading to transparent, so it creates a nice subtle shadow over the background. Since it only uses vertex colors, it can be updated quickly without any texture maps ever being involved. It fakes a bit of the global shadowing effect that tall objects have on the ground around them and makes things feel a lot more grounded.

Lighting overlay

This one was a bit of a project, and it’s still ongoing. The game now tracks the light level of every square in the game, and how much of that light is contributed by on-the-ground lighting instead of from the sky. As the day progresses, the color of the skylight shifts from daytime white through twilight orange into midnight blue. In the day, you can’t see your ground lights because the whole world is fully lit anyway. But at night, they become points of light in the darkness.

Making all this work was a fun exercise in shader writing and mesh generation. As with the edge shadows, the whole system is driven by changing vertex colors. These vertex colors are fed into a shader that overlays a light color over the map. The light color is determined by the vertex colors (which are driven by ground lights) and the sky light color (which updates every frame based on time of day).

Figuring out how ground lights spread was a fun challenge. I actually ended up using a pathfinding routine called Dijkstra’s Algorithm to make the light spill around corners properly. This simulates a sort of radiosity in a 2D tile-based world, and looks far better than just doing everything by straight line of sight.

Lighting isn’t just a visual effect. It affects gameplay.

  • Characters don’t like to be in the dark
  • Darkness affects their ability to do things.
  • Plants need light to grow.

I’m hoping we’ll see things like:

  • Players building over-brightly-lit hydroponic grow ops like something from a pot dealer’s basement.
  • Players setting up combat-field floodlights to illuminate the enemies they want to shoot.
  • Players freaking out when an electrical storm knocks out their power in the middle of a medical operation (causing critical mistakes) or an attack (depriving the defenders of light to shoot by).
  • EMP weapons could create these effects deliberately.
  • Some characters could be afraid of the dark and have extreme reactions to it.

Here’s some lighting shots from a simple base I made. The first is at night, the second at dawn, the third is a detail of the first.

Dark SunsetDarkZoom

Terrain modification

Whereas before terrain was basically just a big fake alpha-blended map that meant nothing, now each square has a specific terrain type.

The visual challenge here was figuring out a way to get every kind of terrain to blend properly with every other kind in arbitrary combinations. This is actually a bit of an open problem in game coding, ad you’ll see if you try googling it.

The system I’m working with now involves giving each terrain type a layering precedence, filling each square with its appropriate terrain type, and then blending neighboring squares in when their precedence is greater than your own. As with the lighting, this is all driven by a set of layered generated meshes that I update when the terrain changes. This way, sand will spill over a concrete walkway a little bit at its edge, while concrete will but up against bricks in a hard edge.

But terrain modification is really as much of a gameplay improvement as anything else. With unambiguous knowledge of terrain, we can do things like:

  • Have terrain affect what can be built where. E.g. you can only farm on soft earth, but you can’t build some kinds of heavy constructions there until you dig them out and change them to concrete.
  • Have terrain affect movement speeds (e.g. you want to build a road to your mining operation)
  • Have terrain affect people psychologically

Hope you enjoyed the update. Work continues at about as fast a pace as is possible without me going insane. I’m loving it.

2 Responses to “Light and dark”

  1. screeching_goat

    I look forward to the lightening!

  2. Hello i am kavin, its my first occasion to commenting anyplace,
    when i read this piece of writing i thought i could also make comment due too this brilliant paragraph.

    Also visit my page; mario kart wii mario games