Parallax: The masker tool

Introduction

  • This tool was 90% of the work.
  • It is a quite intricate, so we'll just scratch the surface here.
  • It's 2780 lines of python code, 9 classes and it generates 30 MB log files per level.

General idea of the tool

  • Simulate a run-through of the level, frame by frame.
  • Use the tiles in the level as a big mask towards the moving parallax sprites.
  • For every frame, store the current, masked representation internally of each parallax sprite.
  • Use heuristics and identify a good starting PAT, and then find the diff for:
    • PAT: from frame to frame in each GROUP.
    • SAT: from frame to frame.
  • Output:
    • .sci: Sprite Color Information (tiny)
    • .ipp: Initial Parallax Positions (SAT) (tiny)
    • .pat: All unique parallax sprite patterns (large)
    • .ptc: PAT changes per frame (large stream)
    • .sat: SAT changes per frame (large stream)

How it works

We already have a tool that generates the level data for the game. This tool was extended to read the tile graphics files as well as the parallax sprite patterns, which in turn was used to simulate one full run-through to produce the masked sprite patterns.

The tool first produces a large mask based on the level. A png with bitdepth 1, like this:

The result will be a tool-internal overview of the needed PAT for every frame. Thus, also the needed updates from one group frame to the next.

Sometimes the needed updates to VRAM is excessive, so, instead of updating the PAT right before the frame is about to be shown on screen, we try to put the update in one of the 15 frames prior. Dubbed a smooth-out process. As a visual aid, I used a simplified image overlay in Tiled to see the cost at every frame as charts before and after this process. In a chart, one change equals 16 pixels in height. Example:

Numbers from level creation 

  • Clearly, the Blackout level is the heaviest. It will have a peak of 6 PAT updates in a frame at runtime as well as 23 updates to SATpn.
  • Blackout was the final level to be made and I pushed most limits. Huge numbers here, and it is the only level that is using 2-page / 32 kB tilesets.
  • Black Hole is cheapest as it is a starfield only, but next in line is Evergreen. Quite cheap - but this level uses only clouds and they use the upper part only, so it makes sense it is cheaper.
  • ...and we also see that 10 levels of parallax costs 1.2 MB of data. Something that you get for free on other systems...

Continue reading via the links in the footer below.


The parallax effect  |  Design of the system  |  The masker tool  |  In-game data consumption and rendering

Comments